自動記憶域期間 と 静的記憶域期間
明解C言語 入門編 > 6. 関数 >
自動記憶域期間 と 静的記憶域期間
Delphi
program Project1;{$APPTYPE CONSOLE}
uses
SysUtils;var
fx: Integer = 0;
i: Integer;procedure func();
const
sx: Integer = 0;
var
// ax: integer = 0; ローカル変数は初期化できません
ax: Integer;
begin
writeln(format('%3d%3d%3d', [ax, sx, fx]));
inc(ax);
inc(sx);
inc(fx);
end;begin
writeln(' ax sx fx');
writeln('---------');for i := 1 to 10 do
func;
end.
実行結果
S:\>lesson053\project1.exe
ax sx fx
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
10 0 0
9 1 1
8 2 2
7 3 3
6 4 4
5 5 5
4 6 6
3 7 7
2 8 8
1 9 9