Hi,
I read some place that if you have two or more modules or files in C,
you can share variables between the these modules or files using the
'extern' keyword. I'm not really sure how to do this and when to do
this. For example, if main.c has:
double some_val; // global
and first.c wants to use the variable and the value that was assigned to
it in a function that main calls, we should do:
extern double some_val; //global
in the file.. or better yet, we should do this in the header file. Is
this correct? When we're declaring this variable in two files, how does
the compiler know not to really 'declare' the variable since it'll be
visible by another file after the linking process.
Could someone explain the use of this keyword to me please, and advise
me when it's right to use it? Thanks
Sona