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
\" = "

etc..

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

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


[EDIT]
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
Read http://www.cplusplus.com/doc/tutorial/constants.html
at Character and string literals section, there you could find some escape characters
Hello,

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 ?

monere

You missed a %.

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