Chinaunix首页 | 论坛 | 博客
  • 博客访问: 347172
  • 博文数量: 78
  • 博客积分: 3380
  • 博客等级: 中校
  • 技术积分: 857
  • 用 户 组: 普通用户
  • 注册时间: 2010-06-16 19:39
文章分类

全部博文(78)

文章存档

2011年(31)

2010年(47)

分类: LINUX

2010-07-01 17:58:57

/* ************************************************************************
 *       Filename:  pipe_popen.tc
 *    Description: 
 *        Version:  1.0
 *        Created:  2010年07月01日 16时17分31秒
 *       Revision:  none
 *       Compiler:  gcc
 *         Author:  chengbin_liu,
 *        Company: 
 * ************************************************************************/

#include
#include
#include
#include
int main()
{
 FILE *input,*output;
 char buff[PIPE_BUF];
 input=popen("ls --help","r");
 output=popen("more","w");

 read(fileno(input),buff,sizeof(buff));
 write(fileno(output),buff,sizeof(buff));

 pclose(input);
 pclose(output);
 printf("\n");
 exit(EXIT_SUCCESS);
 return 0;
}

阅读(2201) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~