以下是我打的程式码
#include <stdlib.h>
#include <stdio.h>
int main()
{
int times=0;
int NUM=123;
int *pNUM=&NUM;
while(times<5){
printf("%p>>>%d\n",pNUM,*pNUM);
pNUM+=1;
*pNUM=NUM;
times+=1;
}
system("pause");
return 0;
}
我的目标是把变量NUM的值123
也写入NUM后面接的4个位址
假设NUM的位址是0x0001
那么结果应该是:
0x0001 值→123
0x0005 值→123
0x0009 值→123
0x000d 值→123
0x0011 值→123
可是编译器显示的只有第一行,也就是
0x0001 值→123
为什么会这样呢?问题是否出在其实后面四个是无法写入的?
菜鸟请各位高手指教orz