自動記憶域期間 と 静的記憶域期間
明解C言語 入門編 > 6. 関数 >
自動記憶域期間 と 静的記憶域期間
C
#include <stdio.h>int fx = 0;
void func(void)
{
static int sx = 0;
int ax = 0;
printf("%3d%3d%3d\n", ax++, sx++, fx++);
}int main(int argc, char* argv[])
{
puts(" ax sx fx");
puts("---------");int i;
for (i = 1; i <= 10; i++)
func();return 0;
}
実行結果
T:\>lesson053\project1.exe
ax sx fx
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
0 0 0
0 1 1
0 2 2
0 3 3
0 4 4
0 5 5
0 6 6
0 7 7
0 8 8
0 9 9