Monday, June 6, 2011

Questions about C++ commands?

How do I use the command that in command prompt is: ';CD C:\'; in C++? I know it should be system(';CD C:\';) but it gets confused due to the backslash. So I put two backslashes but then it skips that command. How do I successfully change the directory to C:\ in C++?Questions about C++ commands?
Hm....



















Unlike Linux or UNIX, DOS using backslash as path driver.

Remember, C/C++ used \ as special char. I u want to use this char, use with double backslash

Ex:

string strcmd =';CD C:\\MYPATH';;Questions about C++ commands?
I answered this question the last time you asked.
The are two possible ways the above code don work



1. You Compile and Run the Code the System(); in the IDE itself

2. You are in the C:\ directory and you want to change from c:\ to say D:\ using cd d:\





In the first case all you have to do is compile the program and don run in the program in The IDE (TC or Visual Studio)itself ... Exit the IDE and double click your compiled exe or go to dos and type the exe name without exe



The Reason you cant run it in your IDE is that when ever you run a process in dos the control gets transferred to the running process which will overwrite the DOS memory in the RAM by doing so disabling sme part of DOS including all you commands such as cd mkdir which are overwrittem ....at the end of the execution its returned to the original state by set of interrupts... This was due to the 640KB barrier....



in second Case



if you are in C:\ directory say C;\documents and settings\some folder

a cd C:\ Should work A ok ... But if you try a CD D:\ will never work it used to in older version of dos ..... if you want to navigate to other D:\ just do a system(D:) without quotes or anything.......

No comments:

Post a Comment