w******g 发帖数: 67 | 1 When I use following code of "popen" to run some shell command in my C++
progarm under Linux, I get the output both on the terminal screen and in the
string variable. How can I ask popen stop putting output on the screen but
only in the string variable. Thanks.
// run the shell command and put the output into string
string FileOperation::runCommand(string command)
{
stringstream msg;
char c;
FILE *output = popen(command.c_str(),"w");
while( (c=fgetc(output))!= EOF )
{ | w******g 发帖数: 67 | 2 Even I change it to popen(command.c_str(),"r"),
It still put output on the screen. |
|