PDA

View Full Version : [SOLVED] to access command prompt



c2tarun
November 12th, 2010, 08:16 PM
hi friends is there a way that i can access command prompt from a C program.
I mean i want to pass some commands to terminal of command prompt via a C program

TiBaal89
November 12th, 2010, 08:23 PM
hi friends is there a way that i can access command prompt from a C program.
I mean i want to pass some commands to terminal of command prompt via a C program

Yes, indeed... system("blah") will run the blah command. If you're running your program from the terminal, the results will be output to that terminal.

Try this out:


#include <stdlib.h>

int main() {

system("ls");

}

EDIT: oops! :D

hakermania
November 12th, 2010, 09:08 PM
You have to

#include <stdlib.h>
to use system()