Like so
Code:
int global; // lifetime of program, scope everywhere
static int local; // lifetime of program, scope is current source file
void foo ( ) {
static int bar; // lifetime of program, scope is current function
int count; // lifetime of function, scope is current function
for ( count = 0 ; count < 10 ; count++ ) {
int temp; // scope is up to the matching }
}
}
For string literals, like
char *s = "this is a string";
the only thing you can be sure of is that "this is a string" has a lifetime of the program. If two source files have the same string constant, then one of them could be removed.
All other initialisation data could be stored in a variety of unspecified ways.
For example
Code:
char msg[] = "hello";
May be implemented as
Code:
char msg[6];
strcpy(msg,"hello");
or
Code:
char msg[6]
msg[0] = 'h';
msg[1] = 'e';
// and so on