1 Star 1 Fork 0

adan shaw / structures-algorithms-in-C

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
bigsmall.c 587 Bytes
一键复制 编辑 原始数据 按行查看 历史
adan-shaw 提交于 2024-02-16 18:32 . update
#include <stdio.h>
#include <limits.h>
void method1 ()
{
int a = 1;
char *p = &a;
if (*p)
printf ("小端\n");
else
printf ("大端\n");
}
union Test
{
short a;
char b;
};
void method2 ()
{
union Test test;
test.a = 1;
if (test.b)
printf ("小端\n");
else
printf ("大端\n");
}
void method3 ()
{
unsigned short limit = (USHRT_MAX + 1) / 2;
unsigned short a = 0;
char name[1];
printf ("输入2字节字符串!\n");
gets (name);
if (a >= limit)
printf ("大端\n");
else
printf ("小端\n");
}
int main (void)
{
method1 ();
method2 ();
method3 ();
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/adan_shaw/structures-algorithms-in-C.git
git@gitee.com:adan_shaw/structures-algorithms-in-C.git
adan_shaw
structures-algorithms-in-C
structures-algorithms-in-C
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891