mainpopen.c
来自「《UNIX进程间通信》中的代码」· C语言 代码 · 共 26 行
C
26 行
#include "unpipc.h"intmain(int argc, char **argv){ size_t n; char buff[MAXLINE], command[MAXLINE]; FILE *fp; /* 4read pathname */ Fgets(buff, MAXLINE, stdin); n = strlen(buff); /* fgets() guarantees null byte at end */ if (buff[n-1] == '\n') n--; /* delete newline from fgets() */ snprintf(command, sizeof(command), "cat %s", buff); fp = Popen(command, "r"); /* 4copy from pipe to standard output */ while (Fgets(buff, MAXLINE, fp) != NULL) Fputs(buff, stdout); Pclose(fp); exit(0);}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?