In C and C++ (and several other languages) horizontal tabulators (ASCII code 9) in character and string constants are denoted in escaped form as '\t'
and "\t"
. However, I am regularly typing the unescaped tabulator character in string literals as for example in "A B"
(there is a TAB in betreen A
and B
), and at least clang++ does not seem to bother - the string seems to be equivalent to "A\tB"
. I like the unescaped version better since long indented multi-line strings are better readable in the source code.
现在我在问自己,这在C和C++中通常是合法的,还是只是我的编译器支持的.未转义的制表器在字符和字符串常量中的可移植性如何?
令人惊讶的是,我找不到这个看似简单的问题的答案,既没有谷歌,也没有Stackoverflow(我只找到了this个模糊相关的问题).