私はポインタを理解しようとしています。このコードを読んで、コンパイルして実行するたびにアドレスが変わります。それはいくつかの迷惑な値ですか、またはポインタは実際に外出先で割り当てられたメモリを取得しますか?Cでプログラムを実行するたびにポインタアドレスが変わるのですか?
私のコマンドプロンプト:
[email protected]:~/Desktop/Learn_C$ ./Practice
nNUmber is equal to : 15
nNumber is equal to : 25
0xbf98fd64
[email protected]:~/Desktop/Learn_C$ make Practice
make: 'Practice' is up to date.
[email protected]:~/Desktop/Learn_C$ ./Practice
nNUmber is equal to : 15
nNumber is equal to : 25
0xbfcce2a4
[email protected]:~/Desktop/Learn_C$ ./Practice
nNUmber is equal to : 15
nNumber is equal to : 25
0xbfa25df4
[email protected]:~/Desktop/Learn_C$ ./Practice
nNUmber is equal to : 15
nNumber is equal to : 25
0xbfecf104
私のCコードは次のとおりです。
#include <stdio.h>
int main()
{
int nNumber;
int *pPointer;
nNumber = 15;
pPointer = &nNumber;
printf("nNUmber is equal to : %d\n", nNumber);
*pPointer = 25;
printf("nNumber is equal to : %d\n", nNumber);
printf("%p\n", pPointer);
return 0;
}
は、事前にありがとうございます。
一般的なセキュリティ機能:[アドレス空間レイアウトのランダム化](https://en.wikipedia.org/wiki/Address_space_layout_randomization) –
なぜdownvote。これは正当な質問です。 – alk