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?

Community
  • 1
  • 1
LennyBorland
  • 51
  • 1
  • 5
  • don't use system. try popen instead: http://linux.die.net/man/3/popen – thang Jan 19 '13 at 01: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. – Jonathan Leffler Jan 19 '13 at 01:24

0 Answers0