C++ 转义字符使用注意

#include <iostream>

int main()
{
    std::cout << "hello, \x4DO\115" << '\n';    //hello, MOM    //普通转义字符直接使用 ‘\n’
    std::cout << "hello, \x4DO\115" << std::endl;    //hello, MOM  //泛化转义字符 \x4D(16进制表示) \115(8进制表示)
    std::cout << "hello, \1154" << std::endl;  //M4 //用8进制表示时,超过三个数字,只有‘\’后三个与‘\’构成转义字符,后面是字符4

    system( "PAUSE ");

    return 0;
}

 

posted on 2019-11-13 12:02  wu.g.q  阅读(1095)  评论(0编辑  收藏  举报

导航