阅读背景:

C语言标准库管道使用_wwxy1995的博客_c语言管道怎么用

来源:互联网 

下面代码使用了C语言标准库中的管道操作

#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <string.h>
int main(void)
{
	FILE *fp;

	fp = popen("cat /etc/passwd", "r");
	char buf[512];
	memset(buf,0,sizeof(buf));
	while(fgets(buf, sizeof(buf), fp) !=NULL)
	{
		printf("%s", buf);
	}
	pclose(fp);

	printf("--------------------\n");
	fp = popen("wc -l", "w");
	fprintf(fp, "1\n2\n3\n");
	pclose(fp);

	return 0;
}#include <stdio.h>
#inclu



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: