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 }
阅读(1155) | 评论(0) | 转发(0) |