I just tried compiling some C++ code that used the literal Tab character (as in I pressed the TAB
key on my keyboard) inside a string. And, to my surprise, it compiled fine. In retrospect I guess that makes sense, since it's a character just like any other.
cout << "Tab: [TAB]";
Before now I've always used \t
to define tabs in strings.
cout << "Tab: [\t]";
Obviously code using literal TAB
s in strings would suffer greatly in readability, but is there a technical reason to use \t
other than convention?