- 31 名前:℃素人 [2009/02/20(金) 09:02:10 ]
- /* プログラム@ */
#include <stdio.h> int main( void ) { int *x,*y; printf("%d\n",(&y-&x)); /* ここでの表示結果は"1" */ return 0; } //------------------------------------------------------ /* プログラムA */ #include <stdio.h> int main( void ) { int *x,*y; printf("%d\n",sizeof(&y-&x)); /* ここでの表示結果は"4" */ return 0; } //------------------------------------------------------- プログラムAではsizeof演算子を付けて 望んでいた結果の"4"が出力されます。 何故、プログラム@では"1"が出力されるのでしょうか? コンパイラは「Microsoft(R)32-bit C/C++ Standard Compiler」です。
|

|