1.数据类型概念
数据类型是固定内存的别名,是创建变量的模子。
1.1相关测试代码
#include <stdio.h>
int main()
{
char c = 0;
short s = 0;
int i = 0;
printf("%d, %d\n", sizeof(char), sizeof(c));
printf("%d, %d\n", sizeof(short), sizeof(s));
printf("%d, %d\n", sizeof(int), sizeof(i));
return 0;
}
实验结果
2.变量的本质
-变量是一段实际连续空间的别名
-程序中通过变量来申请并命名存储空间
-通过变量的名字可以使用存储空间
2.1 相关测试代码
#include <stdio.h>
typedef int INT32;
typedef unsigned char BYTE;
typedef struct _tag_ts
{
BYTE b1;
BYTE b2;
short s;
INT32 i;
} TS;
int main()
{
INT32 i32;
BYTE b;
TS ts;
printf("%d, %d\n", sizeof(INT32), sizeof(i32));
printf("%d, %d\n", sizeof(BYTE), sizeof(b));
printf("%d, %d\n", sizeof(TS), sizeof(ts));
return 0;
}
实验结果