int check_sys()
{
int a = 1;
char *p = (char *)&a;
if (*p == 1)
return 0;
else
return 1;
}
int main()
{
int ret = 0;
ret = check_sys();
if (ret == 0)
printf("little");
else
printf("big");
system("pause");
return 0;
}
方法二:利用共用体union
int check_sys()
{
union UN
{
char c;
int i;
}un;
un.i = 1;
if (un.c == 1) return 0;
else return 1;
}
int main()
{
int ret = 0;
ret = check_sys();
if (ret == 0)
printf("little");
else
printf("big");