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?

popen is a useful function for this purpose:

https://www.systutorials.com/docs/linux/man/3p-popen/

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

Leave a Reply

Your email address will not be published. Required fields are marked *