Accessing an array across files in C -
i'm trying access array across files, this;
int option[number_of_options]; ... addition(&option[0], num1, num2); ... printf("%d", option[0]); thats first(main) file
and second this;
void addition(int * option, unsigned number1, unsigned number2) { int total = number1 + number2; ... *option ++; } something that. dont worry addition method.
the problem printf method allways prints 0, if *option ++; never executed/read.
how fix this?
by way, warning in "*option++;" file saying: warning: value computed not used.
how solve problem?
thank you!
this:
*option++; doesn't think does. means is:
*(option++); which first applies increment operator option pointer , dereferences afterwards. effect is:
option++; *option; // statement no effect, hence warning. you need instead:
(*option)++;
Comments
Post a Comment