#include <stdio.h>
void f (void)
{
static int count = 0; // static variable
int i = 0; // automatic variable
printf("%d %d\n", i++, count++);
}
int main(void)
{
for (int ndx=0; ndx<10; ++ndx)
f();
}
For example, in this code, where is count
stored? Usually, static
variables will be stored in the Data segment, and local variables are stored on the stack.