If you are running a program that inputs from the terminal, then ctrl-D is the end of file marker. Typically you would have to enter the ctrl-D on a new line.
If this doesn't work, then perhaps there is a problem in the code. Does it work when redirecting input from a file?
I'm assuming you are using a bash shell under linux?