可能重复:
如何在 C++ 中执行命令并获取命令输出?
在我的 c++ 程序中,我正在使用 execv/system 运行一个外部程序。
我想将程序的输出重定向到我程序中的缓冲区,即:
char* buff[some size large enough for any possible output];
system(some program);
//THE PROGRAM I JUST RAN IS A SPECIAL BLACK BOX PROGRAM THAT RUNS
//AND PARSE AN HTTP DUMP FILE AND PRINTS IT TO THE SCREEN WHEN RUNNING
//I WANT THE OUTPUT TO GO A BUFFER IN MY PROGRAM.
//THE IDEA IS TO HAVE THE DATA OF THE OUTPUT ON THE BUFFER RATHER THAN ON A FILE
//have the buffer filled with the output of the program
谢谢 :-)