Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
System call in C
Name: vinit Date: January 30, 2002 at 22:05:55 Pacific
Comment:
In shell prompt if we try to cd .. ,it goes to previous directory.But in C program system(cd ..) does not work.
main() { system("cd.."); return 0; } You need to include the quotes.
0
Response Number 2
Name: vinit Date: January 31, 2002 at 21:10:54 Pacific
Reply:
main() { //if i run this program from $\root\vst\vst int i = System("cd .."); //now i=0, means success system("pwd"); //it shows $\root\vst\vst,not\\parent directory } In fact I have to write a command in program to change directory.System("cd..")could not solve my problem.
0
Response Number 3
Name: Guy Date: February 2, 2002 at 18:46:16 Pacific
Reply:
The 'system' call forks a new shell (I'm fairly sure), so it goes out, does the "cd .." and exits. Control returns and you are now in the 'old' shell and the 'old' directory.
You want to use the 'chdir' routine, not 'system'.
HTH, Guy
0
Response Number 4
Name: vinit Date: February 4, 2002 at 04:13:37 Pacific
Reply:
I tried Chdir routine.Stll my perpose is not solved.
Summary: is there a way to in c++ call other system functions within the program, and display the results to the screen as output? for example: system("dir c:\ /w"); i know that doesn't work, but hopefully you...
Summary: I am using this function below to execute a script that I wrote in C++. However, it is not running and not providing an error message. The system executing part of the statement runs (because I could ...