In order to redirect stdin and stdout in a shell environment I just do this:
./exefile < file.in >file.out

But how can I do this programatically, inside the program, that is, that a program redirect itself its own stdin and stdout??

thanx.