Yes, you can include a tab character in a string or character literal, at least according to C++11. The allowed characters include (with my emphasis):
any member of the source character set except
the double-quote"
, backslash\
, or new-line character
(from C++11 standard, annex A.2)
and the source character set includes:
the space character, the control characters representing horizontal tab, vertical tab, form feed, and new-line, plus the following 91 graphical characters
(from C++11 standard, paragraph 2.3.1)
UPDATE: I’ve just noticed that you’re asking about two different languages. For C99, the answer is also yes. The wording is different, but basically says the same thing:
In a character constant or string literal, members of the execution character set shall be represented by corresponding members of the source character set or […]
where both the source and execution character sets include
control characters representing horizontal tab, vertical tab, and
form feed.