这是本人写的测试是小端法还是大端法的代码,
# include <stdio.h>
#define BOOL int
BOOL BigOrLittle_endian(void)
{
union{
int x ;
char ch ;
}tagUnion ;
tagUnion.x = 1 ;
return (tagUnion.ch == 1) ;
}
int main()
{
printf("%d\n" , BigOrLittle_endian()) ;
return 0 ;
}
# include <stdio.h>
#define BOOL int
BOOL BigOrLittle_endian(void)
{
union{
int x ;
char ch ;
}tagUnion ;
tagUnion.x = 1 ;
return (tagUnion.ch == 1) ;
}
int main()
{
printf("%d\n" , BigOrLittle_endian()) ;
return 0 ;
}
愿用余生致力编程