info:c_global_local
This is an old revision of the document!
Variables in C
static global variables
Test case: Code for c1.c:
#include <stdio.h> static int stat; int getSetStat1(int n) { int v = stat; stat = n; return v; } int main(void) { getSetStat2(4); getSetStat1(3); printf("stat.1=%i, stat.2=%i\n",stat, getSetStat2(5)); return 0; }
Code for c2.c:
static int stat; int getSetStat2(int n) { int v = stat; stat = n; return v; }
Compile with gcc c2.c c1.c
. Output: stat.1=3, stat.2=4
.
info/c_global_local.1263467623.txt.gz · Last modified: 2010/01/14 11:13 by moritz