[try Beta version]
Not logged in

 
Using '\'

Dec 16, 2008 at 1:11am
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?
Dec 16, 2008 at 1:18am
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 \\.
Dec 16, 2008 at 1:21am
Add in another \. Like.

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


[EDIT]
Woops. I was late...lolz.
Last edited on Dec 16, 2008 at 1:22am
Dec 16, 2008 at 6:07am
Thanks, works perfectly. =]

Also, in VC++ 2008, isn't it \a for a beep? \b does nothing. :P
Dec 16, 2008 at 12:32pm
Read http://www.cplusplus.com/doc/tutorial/constants.html
at Character and string literals section, there you could find some escape characters
Dec 17, 2008 at 3:04am
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

Dec 17, 2008 at 4:10am
You missed a %.

system("%ProgramFiles%\\Windows NT\\Accessories\\wordpad.exe");
Last edited on Dec 17, 2008 at 4:10am
Topic archived. No new replies allowed.