1

Possible Duplicate:
Capturing stdout from a system() command optimally

I'm trying to call the function system() and read in what ever output it would produce on the command processor.

//system acts as a command processor
char string[250];
system("ls");

//put result into string

return 0;

What would be a good way to go about it?

2
  • don't use system. try popen instead: linux.die.net/man/3/popen Commented Jan 19, 2013 at 1:23
  • 1
    Welcome to Stack Overflow. You've asked a perfectly good question; however, it has also been asked before, and the 'possible duplicate' comment tells you of at least one answer to the same question. Commented Jan 19, 2013 at 1:24

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.