数据类型
字符类型
char
(signed) char c = 'a';
signed char c = 'a';
分配1个字节存储区, 打了个标签为c, 将字符'a'对应的数字放到该字节中
int - 4字节 - %d
char - 1字节 - half half %d - %hhd
整型
short
int
long
转义字符 :
''
'n'
'\n' - 换行符
'\r' - 当前行行首
printf("hello\r123456\n");
123456
字符类型也是一个整型数据, 占位符就是%hhd
可以以字符的方式处理该类型, 占位符是%c
例如: char c = 'a';
char c = 97;
区分记忆:
int - %d
unsigned int - %u
short (int) - half %d - %hd
unsigned short (int) - half %u - %hu
long (int) - long %d - %ld
unsigned long (int) - long %u - %lu - sizeof
long long (int) - long long %d - %lld
unsigned long long (int) - long long %u - %llu