If I read you correctly, you are trying to write the password to the C program using a pipe? I have had similar problems. I'm guessing that _getch() on Windows is not using vanilla STDIN but using console features instead (hence the #include <conio.h>).
The way I got around this in C was to use _isatty() (cross-platform), and only use _getch() if we are connected to a tty, otherwise use getchar().