The system function will not work for what you want to do because as soon as system() returns to your program the operating system discards the results of cd and resets the current directory to what it was before the program called system(). This is the same identical behavior of *nix operating systems and *nix shells.
The only way to make your program work is to call the standard C function chdir(), as previously recommended (assuming your operating system supports it, and some do not.)
Last edited by Ancient Dragon; Aug 6th, 2009 at 10:11 pm.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Offline 21,950 posts
since Aug 2005