Passing an array as a function argument from within a function which takes it as an argument in C -
G'day!
If I have a function that takes an array of ints as an argument, and then within that function, send that function to another function, whether it still edits array values And will be divided into the main level instead of the function level?
i.e
int main (int argc, char * argv []) {int a [50]; FunctionB (A); }
Where the function looks like B:
void functionB (int a []) {functionC (a); }
And the function C is the one that actually changes values within A [].
Should see mainly the changed array or the original A []?
Thank you!
Indicator will modify the array then it will modify the original array.
Check it
zero function C (int A []) {a [0] = 1; A [1] = 2; } Zero function B (int a []) {functionC (A); } Int main (int argc, char * argv []) {int a [2] = {5,5}; Printf ("Before the call:% d% d \ n", a [0], a [1]); FunctionB (A); Printf ("After call:% d% d \ n", a [0], a [1]); }
Comments
Post a Comment