Using '\'

I undesrstand (I think) that when used '\', it cancels out whatever comes after it. Now, for my menu in my C++ Console App, I need to use this '\' in a cout statement. More specifically: cout << "/------------------------------\"; but it doesn't register the ending " because the '\' is in front of it. Is there any way around this?
It doesn't do that exactly. It is the specifier for 'special' characters, i.e.:

\n = newline
\b = beep
\" = "


To put a normal \, use \\.
Add in another \. Like.

cout << "/------------------------------\\";

Woops. I was late...lolz.
Last edited on
Thanks, works perfectly. =]

Also, in VC++ 2008, isn't it \a for a beep? \b does nothing. :P
at Character and string literals section, there you could find some escape characters

I tried your solution with the follwing system instruction, but it did not work. i got an errror statement indicating that the \w was not an escape character.

system("ProgramFiles%\\Windows NT\\Accessories\\wordpad.exe");

can you help me ?


You missed a %.

system("%ProgramFiles%\\Windows NT\\Accessories\\wordpad.exe");
Last edited on
Topic archived. No new replies allowed.