c++获取命令行输出
How to get the output of a system command in C?
The system
function is handy. But how to get the output?
system
功能方便。 但是如何获得输出呢?
popen
is a useful function for this purpose:
popen
是用于此目的的有用函数:
https://www.systutorials.com/docs/linux/man/3p-popen/
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
.
您可以使用fgets
类的常规文件操作功能从popen
打开的文件中读取文件内容。
Answered by anonymous.
匿名回答。
翻译自: https://www.systutorials.com/how-to-get-the-output-of-a-system-command-in-c/
c++获取命令行输出