How to get the output of a system command in C
Posted on In QAHow 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
.