How to get the output of a system command in C

How to get the output of a system command in C?

The system function is handy. But how to get the output?

asked Dec 6, 2013 by anonymous

1 Answer

 
Best answer

popen is a useful function for this purpose:

http://www.pkill.info/linux/man/3p-popen/

You can use normal file operation functions like fgets to read file content from the file opened by popen.

answered Dec 6, 2013 by anonymous

Please log in or register to answer this question.

Copyright © SysTutorials. User contributions licensed under cc-wiki with attribution required.
Hosted on Dreamhost

...