由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - question about "popen" in C/C++
相关主题
[转载] 简单的题都不敢做了.C++ template question with friend ostream
标 题: 发包子 echo 求助问一道C++面试题
How to execute a shell command in java and display the output?C++ output format problem
java 里可以插入linux command吗? (转载)问一个C++文件读取的问题
C++ Q13: InputC++ formatted output question
请教一个C++的问题【求助】Centos里面怎么没有g++? (转载)
Design question: how to create installation package to cov在linux 和 Unix 上做 C/C++ 有差别吗?
c++ 是否也有class method??About command line in C++
相关话题的讨论汇总
话题: popen话题: output话题: c++话题: string话题: command
进入Programming版参与讨论
1 (共1页)
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.
1 (共1页)
进入Programming版参与讨论
相关主题
About command line in C++C++ Q13: Input
Questions about C++ Linux Command Line Parsing请教一个C++的问题
c++设计一问:如何动态地调用不同的算法的dll ?Design question: how to create installation package to cov
a few very simple python commandsc++ 是否也有class method??
[转载] 简单的题都不敢做了.C++ template question with friend ostream
标 题: 发包子 echo 求助问一道C++面试题
How to execute a shell command in java and display the output?C++ output format problem
java 里可以插入linux command吗? (转载)问一个C++文件读取的问题
相关话题的讨论汇总
话题: popen话题: output话题: c++话题: string话题: command