1. #include <iostream>
    2. using namespace std;
    3. int main() {
    4. // 1、字符型变量创建方式
    5. char ch = 'a';
    6. cout << "ch = " << ch << endl;
    7. // 2.字符型变量所占的内存大小
    8. cout << "ch所在内存空间大小" << sizeof(ch) << endl;
    9. // 3.字符型变量常见错误
    10. // char ch2 = 'b'; // 创建字符型变量需要单引号
    11. // char ch3 = 'abcdef'; // 创建字符型变量时候、单引号内只能有一个字符
    12. // 4.字符型对应的ASCII编码 a - 97 A - 65
    13. cout << (int)ch << endl;
    14. system("pause");
    15. return 0;
    16. }