当前位置:网站首页>写一个C程序判断系统是大端字节序还是小端字节序
写一个C程序判断系统是大端字节序还是小端字节序
2022-06-30 06:30:00 【鄧二寶official】
Demo:
#include <stdio.h>
int check_sys(int a)
{
return *(char *)&a;
}
int main(int argc, char **argv)
{
int a = 1; /* 00 00 00 01 */
int ret = check_sys(a);
if(ret == 1) /* 01 */
{
printf("little endian\n");
}
else /* 00 */
{
printf("big endian\n");
}
return 0;
}
边栏推荐
猜你喜欢
随机推荐
Problems related to pinduoduo store search, why can't new products be found on the shelves
Gazebo model modification
Thread safe solutions, communication between threads (classic examples of producers and consumers)
Docker is equipped with the latest MySQL image
My experience in functional testing for so many years
Jgaurora A8 configuration file
[database] transaction
Beauty of Refactoring: when multithreaded batch processing task lifts the beam - Universal scaffold
VIM view file code
Subnet division and subnet summary
1.2(补充)
[untitled]
Practice summary of Prometheus project in amu Laboratory
C language final experiment report (student achievement management system) source code
【我的创作纪念日】一周年随笔
关于Glide加载图片模糊不清楚
一个完整的性能测试流程
Base64 explanation: playing with pictures Base64 encoding
银河麒麟初体验
Collection and method of traversing collection elements (1)