views:

25

answers:

0

I am running Eclipse CDT (Helios) for C/C++ on Windows 7 x64. At first I was having the problem of output not appearing when run in the Eclipse console until the program exited, even though it did while running in a Windows console. I discovered this had to do with buffering on the stdout stream. I was able to disable the buffering with the following:

setvbuf(stdout, NULL, _IONBF, 0);

But now I cannot figure out why kbhit() always returns 0 even when keys are pressed in the console. I tried disabling buffering on stdin:

setvbuf(stdin, NULL, _IONBF, 0);

But this had no effect. My program is a shell application. I am using kbhit() and getch() to read input, which works when the program is run in a Windows console, but not in the Eclipse console. What am I missing here?