Archived

This topic is now archived and is closed to further replies.

Command prompt and compiler problem

This topic is 5150 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

On the command prompt, if you type "cd\" it will go to the C:\ Drive. But in my C++ compiler, if i put: system ("cd\"); it doesn''t work. Obviously, because if I use ''\'' in the line it will read it as a command, so you will have to put something after it like an ''n''. Can anyone tell me how to fix this problem, so I make the command prompt send the ''cd\'' while still using my C++ compiler?

Share this post


Link to post
Share on other sites
In C and C++, the ''\'' character in a string denotes an escape sequence. The escape sequence for the ''\'' character itself is "\\". Thus in this case, what you want is "CD\\".

Share this post


Link to post
Share on other sites
Also note that system("CD\\") is a worthless command in a program, because a separate environment is invoked for it. It won''t change the actual working directory for your program.


"Sneftel is correct, if rather vulgar." --Flarelocke

Share this post


Link to post
Share on other sites