[C言語]変数がメモリ上にどのように領域確保されているかを見てみる

実行結果
Windows7 32bit, gccでコンパイル・実行してみました。
address of c1 is 0022FEF9
address of c2 is 0022FEFA
address of c3 is 0022FEFB
address of i1 is 0022FEFC
address of i2 is 0022FF00
address of i3 is 0022FF04
address of d1 is 0022FF08
address of d2 is 0022FF10
address of d3 is 0022FF18
それぞれのアドレスの差分を見ると、
charは1バイト
intは4バイト
dobuleは8バイト
になっていることがわかりました。

また、変数がメモリ上に隙間なく並んでいる様子もわかります。
カテゴリ: