这是一个关于管道通信的
#include <stdio.h>
main()
{
int x,fd[2];
char buf[30],s[30];
pipe(fd);
while((x=fork())==-1);
if(x==0)
{
sprintf(buf,"This is an example\n");
write(fd[1],buf,30);
exit(0);
}
else
{
wait(0);
read(fd[0],s,30);
printf("%s",s);
}
}
这是我照搬书上的。居然编译出错.....
pipe fork write exit系统都说 undeclared identifier