运算符优先级问题,C达人请进

来源:百度知道 编辑:UC知道 时间:2024/09/20 12:17:20
ANSI C,如下的语句得出什么结果?

其中0x0800地址空间存放的是0x1234,0x0801地址空间存放的是0x5678

*((unsigned int *)0x0800+1)
最佳答案是错误的。实际答案应该是:*((unsigned int *)0x0800+1) 相当于(unsigned int *)0x0800看作一个unsigned int 型的指针,+1,会向后跳一个int的长度;具体是几字节要看是什么芯片。
参见:http://topic.csdn.net/u/20080805/10/87175a61-4808-4c93-bb61-f3b8e7cbeab9.html?1251353450

首先执行(unsigned int *)0x0800得到0x5678。
所以(unsigned int *)0x0800+1=0x5678+1=0x5679
所以*((unsigned int *)0x0800+1)=*(0x5679)
所以应该是得到0x5679地址空间存放的值。

晕···想这种问题做什么~
想不通就学汇编去吧~