GIDForums  

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 22-Aug-2003, 22:48
kyle kyle is offline
New Member
 
Join Date: Aug 2003
Posts: 1
kyle is an unknown quantity at this point
Unhappy

i = system ("cd c:\text"); :(


CPP / C++ / C Code:
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
int main ()
{
  int i,j;
  puts ("Trying to execute command CD ");
 [b] i = system ("cd c:\text"); [/b]
  if (i==-1) puts ("Error executing CD");
  else puts ("Command successfully executed");

 puts ("Trying to execute command del ");
 [b] j = system ("del *.txt"); [/b]
  if (j==-1) puts ("Error executing del");
  else puts ("Command successfully executed");

 getchar();
  return 0;
}
s c

It won't work. How do I make this go to a specific directory? I know if i just make it i = system ("cd"); that it will print the current directory. Is there a way to change directories this way?
  #2  
Old 25-Aug-2003, 11:43
Garth Farley Garth Farley is offline
Awaiting Email Confirmation
 
Join Date: May 2002
Location: Ireland
Posts: 638
Garth Farley is a jewel in the roughGarth Farley is a jewel in the roughGarth Farley is a jewel in the rough
That doesn't work, because every time you call system, it spawns a new process, and the previous settings are lost. Try using chdir() instead, which is included in the unistd.h lib!

GF
 
 

Recent GIDBlogNot selected for officer school by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I detect flash version on my computer system? rhino1616 Graphics Forum 2 23-Oct-2003 09:14
PHP doc system - for when you need to write up some documentation jrobbio MySQL / PHP Forum 0 22-May-2003 08:43
CVS - Concurrent Versions System JdS Web Hosting Forum 6 23-Oct-2002 09:06

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 20:33.


vBulletin, Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.