So, i'm reading about the Extern specifier and there's a couple of things i'm not quite getting and i thought maybe someone here could help me
The book i'm reading states that "we declare a global variable in file A, and then declare the variable again using the extern specifier in file B"
So, in file A i'd place
int i;
and in file B
extern int i; ??
The most confusing part is "You can ignore the extern specifier, but include an
initializer, when you declare a global variable."
so if i initialize a global variable like such
int i = 10;
does this mean i no longer need extern to make it visible on other source files?
"You should use the extern specifier (without an initializer) when you allude to a
global variable defined elsewhere."
Does this mean that i should not initialize the global variables but
rather make them extern and initialize them in the individual source files?
Sorry if the question seems dumb... but, i'm kind of a noob so :P



LinkBack URL
About LinkBacks



