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

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -