010.数据类型-字符型

#include <iostream>
using namespace std;
int main()
{
    //1.字符型变量创建方式,单引号,引号内只有一个字符
    char ch = 'd';
    //2.字符型变量所占用内存大小(1个字节)
    cout << sizeof(char) << endl;
    //3.字符型变量常见错误
    /*char ch2 = "b";错误*/     
    //使用单引号,只能放一个字符;

    //4.字符型变量对应ASCII编码
    cout<<(int)ch<<endl;
    

    system("pause");
    return 0;
}

 

posted @ 2021-09-02 23:03  梦之心  阅读(94)  评论(0编辑  收藏  举报