私はいくつかの割り当てられた値 'i'のポインタと、%uと%lu、%lluに2つの異なるアドレスが割り当てられていることを知りました。どの変数が実行の同じインスタンスで2つの異なるアドレスを持つことができる可能性がある -変数はどのようにして同じ時点で2つの異なるアドレスを持つことができますか?
#include <stdio.h>
int main(void)
{
int i;
float f;
printf("\nEnter an integer:\t");
scanf("%d",&i);
printf("\nValue of address of i=%u",&i);
printf("\nvalue of address of i=%d",&i);
printf("\nValue of address of i=%lu",&i);
printf("\nValue of address of i=%llu",&i);
printf("\nvalue of i=%d",i);
printf("\nvalue of i=%u",i);
printf("\nvalue of i=%lu",i);
printf("\nvalue of i=%llu\n",i);
}
これが出力されます - ここで
[email protected]:~/Desktop/Daily programs/pointers$ ./pointer001
Enter an integer: 12
Value of address of i=1193639268
value of address of i=1193639268
Value of address of i=140725797092708
Value of address of i=140725797092708
value of i=12
value of i=12
value of i=12
value of i=12
我々ははっきりと見ることができ、その%uのためと%Dアドレスは1193639268です(%dと%uの出力はすべての場合で同じではないかもしれません)。%luと%lluの出力は140725797092708で、物理的な意味は何ですか?
詳細: 'void *'ポインタを出力するための適切な書式指定子は ''%p "'です。 ''%p "'は 'int *'に対しては機能しないかもしれませんが、それでも共通です。 – chux
@chux良い点。その詳細を追加しました – dbush