char类型用于存储字符(比如字母或者标点),但是从技术层面讲,char类型是整数,因为char类型存储的是整数而不是字符。 计算机使用字符编码来处理字符,即
用特定的整数来表示特定的字符。 例如在ASCII编码中, 大写字母A存储的是65.
char类型通常被定义为8位的存储单元。 通常1个字节被定义为char类型占用的位数
程序测试:
#include <stdio.h> int main(void) { char ch; printf("Please input an letter: "); scanf("%c", &ch); printf(" letter is: %c. ", ch); printf("integer: %d. ", ch); return 0; }