Anıl Erturk Anıl Erturk - 1 year ago 111
C Question

Are global variables in C automatic variables?

I was studying ANSI C programming language and it says in introduction:

"Local variables are typically "automatic", or created anew with each invocation."

I'm guessing allocating and deallocating variables work with stack frame logic of java. So are global variables automatic too? They would get in and out of stack frame much less than local variables since they are in the scope of the whole .c file(I dont know how scope of variables you call from other files work).

Answer Source

No, these concepts don't play each other. The term global variable is an informal notion, that refers to variables with external linkage. By definition, the automatic variables have no linkage, hence it does not make sense to have variable, that is both automatic and global.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download