ref
数据类型
整数类型
类型 | 大小 | 范围 |
---|
char | 1byte | -128~127 |
unsigned char | 1byte | 0~255 |
int | 2/4byte | -32768~32767 /
−
2
31
-2^{31}
−231~
2
31
−
1
2^{31}-1
231−1 |
unsigned int | 2/4byte | 0~65535 /
0
0
0~
2
32
−
1
2^{32}-1
232−1 |
short | 2byte | -32768~32767 |
unsigned short | 2byte | 0~65535 |
long | 4/8byte |
−
2
31
-2^{31}
−231~
2
31
−
1
2^{31}-1
231−1 /
−
2
63
-2^{63}
−263~
2
63
−
1
2^{63}-1
263−1 |
unsigned long | 4/8byte |
0
0
0~
2
32
−
1
2^{32}-1
232−1 /
0
0
0~
2
64
−
1
2^{64}-1
264−1 |
long long | 8byte |
−
2
63
-2^{63}
−263~
2
63
−
1
2^{63}-1
263−1 |
- 16位操作系统: int占2字节, long占4字节
- 32位操作系统: int占4字节, long占4字节
- 64位操作系统: int占4字节, long占8字节
浮点类型
类型 | 大小 | 范围 | 精度 |
---|
float | 4byte | 1.2E-38~3.4E+38 | 6有效位 |
double | 8byte | 2.3E-308~1.7E+308 | 15有效位 |
long double | 16byte | 3.4E-4932~1.1E+4932 | 19有效位 |
![](https://img-blog.csdnimg.cn/img_convert/478aca7eb83fd2fec532d9b82958d600.jpeg)
嵌入式常用替换
typedef char int8;
typedef volatile char vint8;
typedef unsigned char uint8;
typedef volatile unsigned char vuint8;
typedef int int16;
typedef unsigned short uint16;
typedef long int32;
typedef unsigned long uint32;
存储类
运算符
^
: 亦或, 相异=1&
: 返回变量地址*
: 指向一个变量?:
: 条件表达式(a==10)?20:30
优先级
函数
- 传值调用: 实际值赋值给函数的形参, 此时修改形参不影响实参
- 引用调用: 传指针给形参, 操作时相当对实参本身操作
作用域