#include<stdio.h>
main()
{
int v=1,bit;
char *p;
char temp;
p=&v;
(*p==1)?printf("your cpu follow little endian\n"):printf("your cpu follow big endian\n");
for(bit=31;bit>=0;bit--)
{
printf("%d",(v>>bit)&1);
if(bit%8==0)
{
printf(" ");
}
}
printf("\n");
temp=*p;
*p=*(p+3);
*(p+3)=temp;
temp=*(p+2);
*(p+2)=*(p+1);
*(p+1)=temp;
(*p==1)?printf("now your cpu follow little endian\n"):printf("now your cpu follow big endian\n");
for(bit=31;bit>=0;bit--)
{
printf("%d",(v>>bit)&1);
if(bit%8==0)
{
printf(" ");
}
}
}
No comments:
Post a Comment