Initial commit: C language learning code

This commit is contained in:
2025-07-20 16:30:56 +08:00
commit 06e24173a6
139 changed files with 9303 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <stdbool.h>
#include <string.h>
// !联合
/*
1.存储
所有的成员共享一个空间
同一时间只有一个成员是有效的
union的大小是其最大的成员
2.初始化
对第一个成员做初始化
*/
typedef union {
int i;
char ch[sizeof(int)];
} CHI;
int main()
{
CHI chi;
int i;
chi.i = 1234;
for ( i=0; i<sizeof(int); i++)
{
printf("%02hhx", chi.ch[i]);
}
printf("\n");
return 0;
}