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;
}

猜你喜欢

转载自www.cnblogs.com/wuguoqiang/p/11847939.html