I can't understand why the "\" doesn't appear when i run the program. I want to make some ASCII Art and "\" is basic for the picture i want to make.Is there any solution? I am using Code Blocks .
Asked
Active
Viewed 1,685 times
3 Answers
3
With C++2011 you can use raw string literals, e.g.:
std::cout << R"(\)" << '\n';
The sequence R"(
starts the string and )"
ends the string. If the string )"
needs to be embedded into the string, you can add some string between the "
and the (
which then needs to be repeated between the )
and the "
to end the string.
Of course, it may just be simpler to escape the escape character and to use \\
as you already mentioned.

cHao
- 84,970
- 20
- 145
- 172

Dietmar Kühl
- 150,225
- 13
- 225
- 380
1
You have to use 2 \ since the \ character is known as an escape key, like if you want to go to the next line you have to use \n and that lets C++ know that you want to move to the next line, so every time you use the \ character, you have to type it like \
0
I've found it. You have to enter 2 times the "\" and then it will appear.

Manuel Pap
- 1,309
- 7
- 23
- 52
-
2Yes please read [Escape Sequences](http://en.wikipedia.org/wiki/Escape_sequences_in_C). – Jesse Good Jul 26 '13 at 21:52