Chinaunix首页 | 论坛 | 博客
  • 博客访问: 118522
  • 博文数量: 41
  • 博客积分: 1695
  • 博客等级: 上尉
  • 技术积分: 430
  • 用 户 组: 普通用户
  • 注册时间: 2006-10-21 22:50
文章分类

全部博文(41)

文章存档

2010年(1)

2007年(23)

2006年(17)

我的朋友

分类: C/C++

2007-04-06 10:41:54

  1 #include
  2 #include
  3
  4 int main()
  5 {
  6         int x, fd[2];
  7         char buf[30], s[30];
  8         pipe(fd);
  9         while ((x = fork()) == -1);
 10         if (x==0)
 11         {
 12                 sprintf(buf, "This is an example!\n");
 13                 write(fd[1], buf, 30);
 14                 exit(0);
 15         }
 16         else
 17         {
 18                 wait(0);
 19                 read(fd[0], s, 30);
 20                 printf("%s",s);
 21         }
 22         return 0;
 23 }
阅读(1110) | 评论(0) | 转发(0) |
0

上一篇:read, write, lseek 练笔

下一篇:用户设置ID

给主人留下些什么吧!~~