We know that we can share external variables between different c files using extern keyword but during declaration in second c file using extern keyword . Is memory also allocated to the variable originally defined in first c file and declared in the second c file?


Without explaining the whole thing myself I think I should just guide you to a link which explains the extern keyword well. The short answer, in my own words, is a variable can only be defined once and that definition is what is doing the memory allocation. Anything else that reference that definition in scope is just a reference to the same memory.

Understanding "extern"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .