#include<iostream>
#include<sys/types.h>
#include<sys/wait.h>
#include<unistd.h>
using namespace std;



int main (void) {
       int pid;
       int pipefd[2];
       int v=0;
       //try exception
       try{
           pipe (pipefd);
           pid=fork();
       } catch (exception &e) {
              cout << e.what() <<endl;
              exit (0);

       }

       if (pid==0){
           for (int i=0;i<100;i++) {
                v=i;
                write(pipefd[1],&v, sizeof(int));
           }
           close(pipefd[1]); 
       } else {
           while (1) {
                 if(read(pipefd[0],&v,sizeof(int))) {
                      cout << v<<endl;
           }else {
           cout<< "-" <<endl;
           }
       }
       }wait (NULL);
return 0;
}
