IPC with PIPE

Hi guys, I'm new to Linux and Unix I have just simple code . But I don't know why it doesn't work ..

But, the outputfile is Blank.. I don't understand why.. Please help me.. Thank you very much

P.S: sorry, I don't know how to edit this post clearly.. it's hard to read.. Please try..

I try to change the code from while(..) to do{.. } while(..) .. it works..

do
{
c[0]=fgetc(fin); // get each character from inputfile
write(fd[1],c,2); // write to pipe

}
while(c[0]!=EOF)

and it's work.. but wrong result.. Because the last c[0] = EOF, it is written to pipe, then while loop check the codition.. ( wrong ofcourse)..
I include if statement like this:

if(c[0]!= EOF)
{
c[0]=fgetc(fin);// get each character from inputfile
write(fd[1],c,2); // write to pipe

}

Problem again.. The output is blank.. so crazy.. please help me..

anyone, help me..
If you don't understand what I post.. ( my English is not good).. please ask me.. thank you..