hi all,
I am beginner in C, I want to execute any DOS command like
"cd <directory Name>"
"dir"
"cls" etc..... Through C program.
Please any can help me .
Thanz in advance.
Printable View
hi all,
I am beginner in C, I want to execute any DOS command like
"cd <directory Name>"
"dir"
"cls" etc..... Through C program.
Please any can help me .
Thanz in advance.
You _Could_ do this, but there exists functions for EACH of these in several libs. . . Calling an external program from within your code is generaly considered to be "bad."
Have you tried something like the system command?
eg.
system("dir");
system("cd"); etc...
http://www.thinkage.ca/english/gcos/...ib/system.html
As stated, you could use the system() command but that's sort of OS dependant.
system() can also be dangerous. Imagine if someone mapped "cls" to "bad_trojan-2.5.exe" on some computer.
Hence how it is considered to be "bad."
Aside from that, system("cd foo"); does NOT change the directory of the program itself, much to the surprise of newbies.
The POSIX function chdir() does, however.
Didn't we kill the DOS board?