▪️fateme👷🏻♀️
#include<stdio.h>
int max(int arr[],int n) {
int i;
for(i=0;i<n;i++) {
arr[i]=arr[i]+1;
printf("%d ",arr[i]);
}
}
int main() {
int arr[7]={1,22,5,43,6,42,6},n=7;
max(arr,n);
}
I want the printf operation take place in main() function
Pavel
#include<stdio.h>
void max(int arr[], int n) {
int i;
for(i=0;i<n;i++) {
arr[i]=arr[i]+1;
}
}
int main() {
int arr[7]={1,22,5,43,6,42,6};
int n=7;
max(arr,n);
int i;
for(i=0;i<n;i++) {
printf("%d ",arr[i]);
}
}
Pavel
adnanhossainme
DaviChan
Well somehow there is always a way 😂. But no, it is not supported by default, only overloading the usual operators is
Pavel
You can overload operator[] for your class. It is done for a lot of STL containers
https://en.cppreference.com/w/cpp/language/operators
Anonymous
char CNames[128];
int NumCurr = 0;
int ccyIdx(char* name) { char Ccy[4]; memcpy(Ccy,name,4); Ccy[3] = 0;
for(int n=0; n<32; n++) { if(!CNames[n*4]) { // not yet stored strcpy(CNames+n*4,Ccy); NumCurr++; return n; } if(strstr(CNames+n*4,Ccy)) return n; } return 0; }
In the code above:
Regarding if(!CNames[n*4])
What is the logic? If CNames[n*4] is not what? What am I missing?
Pavel
What do you mean by custom operator, like £ operator? :)
No, unfortunately it's not possible, you are right
Pavel
Anonymous
Pavel
Pavel
This code seem to iterate over chunks 4 byte each, not sure the exact logic
Ольга
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
struct person_str
{
int age;
void input();
void print();
};
void person_str::print()
{
cout<< this->age << endl;
}
void person_str::input(person_str*)
{
person_str p;
cout<<"Enter age: ";
cin>>p.age;
}
int main()
{
person_str p;
p.input(&p);
p.print();
return 0;
}
Hello maybe someone can explain what I do not right. Because I can't understand how it is
Pavel
Pavel
Anonymous
Oh, I think you just made it clearer.
Thank you so much
Ольга
Ольга
Ольга
Anupam2.7
Can we return more than one datatype in a defined function(in c++)?
Because while defining a function we have to specify a datatype too and for eg if we specify int then we can not return char or string datatypes.
Anupam2.7
Does void() function return anything?
Anonymous
No
PI cadaeibfe
How can i fix " error id returned 1 exit status"?
M__
does anyone do leetcode
PI cadaeibfe
#include <iostream>
using namespace std;
int main()
{
cout << "Hello";
return 0;
}
But returns (error id returned 1 exist status) how can i fix this error?
Anonymous
CppCon 2022 @ Denver
Schedule (Ongoing)
https://lnkd.in/gFuauGb3
Watch the recorded videos at
https://www.youtube.com/user/cppcon
The Friday events were live streamed. Sorry about not sharing the link earlier.
Void
#include <stdio.h>
int main()
{
int x,y,z;
for(x=0;x<=100;x++)
{
for(y=0;y<=100;y++)
{
for(z=0;z<=100;z++)
{
if(5*x+3*y+z/3==100&&x+y+z==100&z%3==0);
printf("%d,%d,%d",x,y,z);
}
}
}
return 0;
}
Void
Guys what's wrong with my code
Pavel
▪️fateme👷🏻♀️
#include<stdio.h>
void max(int arr[], int n) {
int i;
for(i=0;i<n;i++) {
arr[i]=arr[i]+1;
}
}
int main() {
int arr[7]={1,22,5,43,6,42,6};
int n=7;
max(arr,n);
int i;
for(i=0;i<n;i++) {
printf("%d ",arr[i]);
}
}
int max();
int main() {
int arr[7]={1,22,5,43,6,42,6},i;
int* result=(int*)malloc(sizeof(int));
for(i=0;i<7;i++) {
*(result+i)=max((arr,7);
}
for(i=0;i<7;i++) {
printf("%d\n",*(result+i));
}
}
int max(int* arr,int n) {
int i;
for(i=0;i<n;i++) {
arr[i]=arr[i]+1;
}
}
Why I can't achieve my desire through this method?
Pavel
int max();
int main() {
int arr[7]={1,22,5,43,6,42,6},i;
int* result=(int*)malloc(sizeof(int));
for(i=0;i<7;i++) {
*(result+i)=max((arr,7);
}
for(i=0;i<7;i++) {
printf("%d\n",*(result+i));
}
}
int max(int* arr,int n) {
int i;
for(i=0;i<n;i++) {
arr[i]=arr[i]+1;
}
}
Why I can't achieve my desire through this method?
What is your desire? :)
Pavel
int max();
int main() {
int arr[7]={1,22,5,43,6,42,6},i;
int* result=(int*)malloc(sizeof(int));
for(i=0;i<7;i++) {
*(result+i)=max((arr,7);
}
for(i=0;i<7;i++) {
printf("%d\n",*(result+i));
}
}
int max(int* arr,int n) {
int i;
for(i=0;i<n;i++) {
arr[i]=arr[i]+1;
}
}
Why I can't achieve my desire through this method?
Your max declaration and definition are different
Pavel
int max();
int main() {
int arr[7]={1,22,5,43,6,42,6},i;
int* result=(int*)malloc(sizeof(int));
for(i=0;i<7;i++) {
*(result+i)=max((arr,7);
}
for(i=0;i<7;i++) {
printf("%d\n",*(result+i));
}
}
int max(int* arr,int n) {
int i;
for(i=0;i<n;i++) {
arr[i]=arr[i]+1;
}
}
Why I can't achieve my desire through this method?
Your max function has int return value, but you don't return anything, this is undefined behavior
Anonymous
ㅤ
int max();
int main() {
int arr[7]={1,22,5,43,6,42,6},i;
int* result=(int*)malloc(sizeof(int));
for(i=0;i<7;i++) {
*(result+i)=max((arr,7);
}
for(i=0;i<7;i++) {
printf("%d\n",*(result+i));
}
}
int max(int* arr,int n) {
int i;
for(i=0;i<n;i++) {
arr[i]=arr[i]+1;
}
}
Why I can't achieve my desire through this method?
Your max function returns nothing here
ㅤ
Void
Void
Ольга
https://onlinegdb.com/iwIfItEAD
Hello! Maybe someone can tell me why this warning appears. Any help would be appreciated
▪️fateme👷🏻♀️
What is your desire? :)
I want whole array as output with everyone get +1
but it didn't work as my expectation
I want to solve it without any return; I want to solve it with assigning dynamic memory
Anonymous
▪️fateme👷🏻♀️
Ольга
Do you understand what that warning means?
Well, it seems that the function is defined to return a value, but I don't return anything with it. But I don't need to return any value, I just need to know if the check is valid or not. Or I mistaken?
Mohamed
hello
Ольга
Mohamed
I am an Angular frontend developer.
I would like to print data online without going through the browser to communicate with my network printer by specifying the printer's ip. Can someone help me with a script or guide me with a package because I don't know the system environment very well?
Гулящий
Hello.
I have a hierarchy of classes, all deriving from one base. I want each of them to print a message upon creation. I don't want to call the printing method every time.
https://godbolt.org/z/19dbhYj9Y
Could you please help?
~
https://github.com/mustafakraizim98/Skyland-Coding-Challenge
Void
Guys can you check my code
Void
#include <stdio.h>
#include <math.h>
int main()
{
float t,p2;
scanf("%f",&t);
if(t<5)
{p2=0;}
else if(t=5)
{p2=2;
}
else if(t>5)
{ t=(t-5)/5;
t=ceil(t);
p2=t*2;
}
printf("%.1f",p2);
return 0;
}
Void
When t=11,p2 should be 4 right?🤔
Captain
Void
~
PI cadaeibfe
BlAnk
Can someone provide me with an idea for a c++ project as i am a beginner for this and internet is providing way too complex ones . It would be helpful if this project actually helps me grow
Anonymous
BlAnk
Bank and hotel management, would I be able complete it within a month
Kanni
Anonymous
Anonymous
Ольга
Pavel
Void
#include <stdio.h>
#include <math.h>
int main()
{
float x;
int p;
scanf("%f",&x);
x=ceil(x);
if(x<3)
{p=10;
}
else if(3<x<=13)
{p=10+2*(x-3);
}
else if(x>13)
{p=10+2*(x-3)+3*(x-13);
}
printf("%d",p);
return 0;
}
Void
I think something is wrong but i can't find out😐
Ольга
Ольга
I found on the Internet that this will help solve the problem (and there is no warning), but now the code does not work as it should
Aleksandr
is it possible to get random element from list?
Strife
Thanks its working now
you're welcome. To be honest, I just searched for your problem on the internet and found the answer. If you have any questions, you can ask them in the group. Certainly, people with a lot of experience can help you, but don't forget that the internet is the answer to all problems.
Aquatica