#include<stdio.h>
unsigned long a=0x12345678;
unsigned char Gu8BufferA[4];
unsigned char Gu8BufferB[4]={0x12,0x34,0x56,0x78};
unsigned long b;
unsigned long *pu32; //ÒýÈëÒ»¸öÖ¸Õë±äÁ¿£¬×¢Ò⣬ÕâÀïÊÇunsigned longÀàÐ͵ÄÖ¸Õë¡£
void main() //Ö÷º¯Êý
{
pu32=(unsigned long *)&Gu8BufferA[0]; //Ö¸Õë¸úÊý×é¡°°ó¶¨¡±£¨Ò²³ÆΪ¡°¹ØÁª¡±£©ÆðÀ´¡£
*pu32=a; //»¯ÕûΪÁã
pu32=(unsigned long *)&Gu8BufferB[0]; //Ö¸Õë¸úÊý×é¡°°ó¶¨¡±£¨Ò²³ÆΪ¡°¹ØÁª¡±£©ÆðÀ´¡£
b=*pu32; //»¯ÁãΪÕû
printf("%lx\n",Gu8BufferA[0]); //°ÑµÚ1¸öÊýGu8BufferA[0]·¢Ë͵½µçÄԶ˵Ĵ®¿ÚÖúÊÖÈí¼þÉϹ۲졣
printf("%lx\n",Gu8BufferA[1]); //°ÑµÚ2¸öÊýGu8BufferA[1]·¢Ë͵½µçÄԶ˵Ĵ®¿ÚÖúÊÖÈí¼þÉϹ۲졣
printf("%lx\n",Gu8BufferA[2]); //°ÑµÚ3¸öÊýGu8BufferA[2]·¢Ë͵½µçÄԶ˵Ĵ®¿ÚÖúÊÖÈí¼þÉϹ۲졣
printf("%lx\n",Gu8BufferA[3]); //°ÑµÚ4¸öÊýGu8BufferA[3]·¢Ë͵½µçÄԶ˵Ĵ®¿ÚÖúÊÖÈí¼þÉϹ۲졣
printf("%x\n",b); //°ÑµÚ5¸öÊýb·¢Ë͵½µçÄԶ˵Ĵ®¿ÚÖúÊÖÈí¼þÉϹ۲졣
while(1)
{
}
}
我改了一下在电脑上运行,发现数据存储是反的,说明我的win7是小端的存储方式 |