Tag: piping

在C中不成功使用popen()?

我可以运行以下命令 xwd -root | xwdtopnm | pnmtojpeg > screen.jpg 在Linux下的终端,它将生成我当前屏幕的截图。 我尝试使用以下代码执行以下操作: #include #include int main() { FILE *fpipe; char *command=”xwd -root | xwdtopnm | pnmtojpeg”; char line[256]; if ( !(fpipe = (FILE*)popen(command,”r”)) ) { // If fpipe is NULL perror(“Problems with pipe”); exit(1); } while ( fgets( line, sizeof line, fpipe)) { //printf(“%s”, line); puts(line); […]