program ending unexpectedly with fork()

view story

http://ubuntuforums.org – I actually wanted to learn about the pipe() command and so I thought I'll fork() a child, take input of an integer array from user in parent process, send that array to child using pipe() and and print the array via child process. While doing this, I am struck with taking input of the array in the parent process at the first place...Whenever I dynamically create an array, say of 5 elements, it takes input of only the first element via the for loop, and as soon as I press the enter key to enter the second element, the program closes. The for loop should be completed..but the program is ending. (Hardware)