我正在尝试通过 system()
启动外部应用程序 - 例如,system("ls")
。我想在它发生时捕获它的输出,以便我可以将它发送到另一个函数进行进一步处理。在 C/C++ 中最好的方法是什么?
最佳答案
来自 popen 手册:
#include <stdio.h>
FILE *popen(const char *command, const char *type);
int pclose(FILE *stream);
关于c++ - 以最佳方式从 system() 命令捕获标准输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/125828/