#include <stdio.h>
#include<stdlib.h>
#include <assert.h>
#include<string.h>
int Check()
{
int a = 0x11223344;
char* p = (char*)&a;
if (*p == 0x44)
{
return 1;
}
return 0;
}
int main()
{
int ret = Check();
if (ret == 1)
{
printf("小端\n");
}
else
{
printf("大段\n");
}
return 0;
}
写一个函数判断当前机器是大端还是小端,如果是小端返回1,如果是大端返回0.
最新推荐文章于 2024-07-08 14:58:49 发布
![](https://img-home.csdnimg.cn/images/20240611030827.png)