Home > Back-end >  With a pointer function, how to pass parameters, just learning c language, a fan
With a pointer function, how to pass parameters, just learning c language, a fan

Time:02-21

CodePudding user response:

Copy function prototype write wrongly, it is good to add a semicolon,
B need an array of type int, so the line call you red is right, wrong is above,

CodePudding user response:

Reference this page down:

CodePudding user response:

Bonus, or an error, remove the asterisk, no pointer to also, I use string pointer, the pointer array type toxic feeling

CodePudding user response:

The building Lord, this Chen () function specific function is not clear, according to the figure changes, for reference:
 # include & lt; Stdio. H> 

Int Chen (int [b], int n, int m);//function declaration
//or: int Chen (int * b, int n, int m);

Int main ()
{
Int c, b;
While (~ the scanf (" % d ", & amp; C))
{
The scanf (" % d ", & amp; B);
//int a [c];
Int * a=new int [c];//dynamic array
Printf (" % d \ n ", Chen (a, c, b));
}

return 0;

}

Int Chen (int [b], int n, int m)//function to achieve
//or: int Chen (int * b, int n, int m);
{
int sum=0;
for(int i=0; i{
[I]=I + 1 b;
}
}

CodePudding user response:

Said the star is removed, the prototype is redundant and a star than function, draw the snake why add foot?

CodePudding user response:

Request to use pointer

CodePudding user response:

reference 4 floor QZJHJXJ response:
the original poster, the Chen () function specific function is not clear, according to the figure changes, for reference:
 # include & lt; Stdio. H> 

Int Chen (int [b], int n, int m);//function declaration
//or: int Chen (int * b, int n, int m);

Int main ()
{
Int c, b;
While (~ the scanf (" % d ", & amp; C))
{
The scanf (" % d ", & amp; B);
//int a [c];
Int * a=new int [c];//dynamic array
Printf (" % d \ n ", Chen (a, c, b));
}

return 0;

}

Int Chen (int [b], int n, int m)//function to achieve
//or: int Chen (int * b, int n, int m);
{
int sum=0;
for(int i=0; i{
[I]=I + 1 b;
}
}

I'll try tomorrow

CodePudding user response:

Asked to use pointer will remove the square brackets,