互联网公司面试题之七
问题:编写一个程序来确定一下你的机器是大端地址还是小端地址。答:实现代码如下:
#include <stdio.h>int main(){ int value = 0x1234; char value_front=*((char *)(&value)); char value_back=*((char *)(&value)+1); printf("value_front=0x%x\nvalue_back=0x%x\n",value_front,value_back); system("pause"); return 0; }
运行结果:
http://dl.iteye.com/upload/attachment/606227/243d9b64-5e37-3275-ab4e-60e374da6550.jpg
页:
[1]