The answer has been given already: \
is special, because it's the escape character, and you need to escape it with itself if you want a literal \
in the outoupt.
This, however, can make the drawing confused.
To improve the things, you can use raw strings literals
printf(R"(--------
----O---
---/|\--
---/-\--)");
Notice that I've truly inserted a line break in place of the \n
escape sequence, because \n
would be literally interpreted as a \
followed by the letter n
.
Clearly, you can still have issues, if a string contains exactly the characters )"
, because it will be detected as the closing token of the string:
// +---- code invalid from here
// |
// v
printf(R"(-----)"---)");
but you can still solve it, for instance by adding another set of wrapping "
s:
printf(R""(-----)"---)"");
or anything else in between the "
and (
, and between )
and "
(not symmetrized):
printf(R"xyz(-----)"---)xyz");
// ^
// |
// +--- not zyx