Computing.Net > Forums > Programming > System call in C

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

Reply to Message Icon

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.



Sponsored Link
Ads by Google

Response Number 1
Name:  
Date: January 31, 2002 at 17:45:54 Pacific
Reply:


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.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: System call in C

Display a system call in C++ www.computing.net/answers/programming/display-a-system-call-in-c/10868.html

System-pause - in c#? www.computing.net/answers/programming/systempause-in-c/10626.html

java system call to C++ program www.computing.net/answers/programming/java-system-call-to-c-program/10126.html