Tan*_*iao 14 c++ string cout char visual-c++
源代码如下.
cout << '\\' << endl; //OK, output is \
cout << '\\\\' << endl; //OK, output is an integer 23644, but why?
Run Code Online (Sandbox Code Playgroud)
该语句cout << '\\\\' << endl;调用类的以下函数ostream.
_Myt& __CLR_OR_THIS_CALL operator<<(int _Val)
Run Code Online (Sandbox Code Playgroud)
我知道写表达式很奇怪'\\\\',但我不明白它为什么不会失败.如何解释结果?
Sim*_*ple 15
这是一个多字符文字并具有类型int.
包含多个c-char的普通字符文字是多字符文字.包含单个c-char的多字符文字或普通字符文字在执行字符集中无法表示,它是有条件支持的,具有int类型,并具有实现定义的值.
你应该使用"\\\\",最后是char const[3]两个\和一个NUL字节.
| 归档时间: |
|
| 查看次数: |
339 次 |
| 最近记录: |