分类: 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;
}