| | |
i = system ("cd c:\text"); :(
![]() |
•
•
Join Date: Aug 2003
Posts: 3
Reputation:
Solved Threads: 0
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
int main ()
{
int i,j;
puts ("Trying to execute command CD ");
i = system ("cd c:\text");
if (i==-1) puts ("Error executing CD");
else puts ("Command successfully executed");
puts ("Trying to execute command del ");
j = system ("del *.txt");
if (j==-1) puts ("Error executing del");
else puts ("Command successfully executed");
getchar();
return 0;
}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?
0
#2 Aug 23rd, 2003
system actually starts a new process, does what you want, then closes that process. in fact, if you really think about it, what does it mean to "change directory"; "change directory" or cd is a Shell implemented feature on the *system* level. With this in mind, you're best bet is to use the standard unix library.
#include <unistd.h>
and the function chdir(char *path)
man chdir
man getcwd
system is the worst function of all time, never use it.
#include <unistd.h>
and the function chdir(char *path)
man chdir
man getcwd
system is the worst function of all time, never use it.
Last edited by subtronic; Aug 23rd, 2003 at 2:56 am.
•
•
•
•
Originally Posted by kyle
Where can I get unistd.h?
Last edited by subtronic; Aug 24th, 2003 at 11:45 pm.
![]() |
Similar Threads
- setting input type="text" values (PHP)
- How put "text" directly next to a variable in a URL? (PHP)
- google "keyword" question (Search Engine Optimization)
Other Threads in the C Forum
- Previous Thread: Help with gui loop.
- Next Thread: Creating a locking program
| Thread Tools | Search this Thread |
#include * adobe ansi array arrays asterisks binarysearch centimeter changingto char character cm convert copyimagefile cprogramme creafecopyofanytypeoffileinc createprocess() database dynamic execv feet fgets file floatingpointvalidation fork function getlogicaldrivestrin givemetehcodez global grade gtkwinlinux hacking histogram inches include incrementoperators infiniteloop input interest intmain() iso kernel keyboard kilometer km license linked linkedlist linux locate looping lowest matrix meter microsoft number oddnumber open opendocumentformat openwebfoundation owf pattern pdf performance pointer posix power probleminc process program programming radix recursion recv recvblocked research reversing segmentationfault sequential single socket socketprograming socketprogramming standard strchr string suggestions systemcall test threads turboc unix urboc user variable voidmain() wab whythiscodecausesegmentationfault windowsapi





