Can anyone tell me how to execute DOS commands using C? I tried the following but it isn't working.
#include%26lt;stdlib.h%26gt;
#include%26lt;stdio.h%26gt;
int main(void)
{
printf("Going to execute a C command");
system("dir");
return 0;
}
Iam just getting the printf statement executed. The dir command isn't working plz help!
C help needed?
I dont code much in windows, but what little I have seen, system command work just as well there.
I tried your code in Linux (with ls replaceing dir) and I got the expected result. So the program works for sure.
tell you what, check if adding a \n at the end of the print line changes things.
I have a feeling, you are running into buffer related issues.
The other thing that you can do is to change the command from dir to something like "mkdir a"
Reply:Try including Dos.h in your program. Write #include %26lt;dos.h%26gt;.
Have Phun Coding :)
sp
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment