#include "ourhdr.h"

int main (void)
{
   int  n,fd[2];
   pid_t pid;
   char line[MAXLINE];

   if (pipe(fd) < 0)
     perror("pipe error");

   if ( ( pid = fork()) < 0 )
     perror("fork error");

   else if (pid > 0) {
    printf(" I am the parent \n");

   if ( ( pid = fork()) < 0 )
     perror("fork error");
    
    if (pid == 0) {

    printf(" I am the second child\n");
    close(fd[0]);
    write(fd[1], "hello world\n", 12);

	}}
  
        else {
          printf(" I am the first child\n");
          close( fd[1]);
          n = read(fd[0], line, MAXLINE);
	  printf(line);
        }

    exit(0);
  }
