If I write putchar('\\t');
while trying to print "\t"
instead of an actual tab, I get the multi character constant warning. On the other hand, if I write putchar('\\');
I get no warning. Upon looking in the ASCII table, there is no character '\\'
, only '\'
. So why is there no warning? Why is '\\'
one character but '\\t'
is more than one? Can a backslash only be used to escape one following character?
\\
is one character, t
is one character, so that is clearly two characters.
\\
is an escape sequence, just like \t
; it means \
.
If you want to print the two characters \
and t
, you clearly need either two calls to putch()
or a function that takes a string argument "\\t"
.
https://en.wikipedia.org/wiki/Escape_sequences_in_C#Table_of_escape_sequences