W
wilson
Dear all,
In this time, I want to pass array to function.
What should I declare the parameter in the function?i
int array[ ] or int array[4]? Which one is correct?
/********************************************************
Below is my code:
********************************************************/
void pass(int var, int element, int array[ ])
{
var = 1;
element = 1;
array[0] = 1;
}
int main()
{
int variable = 0;
int array_element[2] = {0, 0};
int whole_array[2] = {0, 0};
pass(variable, array_element[0], whole_array);
printf("variable=%i ; array_element[0]=%i ; whole_array[0]=%i\n",
variable, array_element[0], whole_array[0]);
system("pause");
return 0;
}
In this time, I want to pass array to function.
What should I declare the parameter in the function?i
int array[ ] or int array[4]? Which one is correct?
/********************************************************
Below is my code:
********************************************************/
void pass(int var, int element, int array[ ])
{
var = 1;
element = 1;
array[0] = 1;
}
int main()
{
int variable = 0;
int array_element[2] = {0, 0};
int whole_array[2] = {0, 0};
pass(variable, array_element[0], whole_array);
printf("variable=%i ; array_element[0]=%i ; whole_array[0]=%i\n",
variable, array_element[0], whole_array[0]);
system("pause");
return 0;
}