Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!zaphod.mps.ohio-state.edu!van-bc!ubc-cs!uw-beaver!milton!sumax!polari!rwing!seaeast!sunbrk!Usenet From: Engbert.Gerrit.IJff@sunbrk.FidoNet.Org (Engbert Gerrit IJff) Newsgroups: comp.lang.c++ Subject: BC++ and kbhit(), getch() calls Message-ID: <675530092.0@sunbrk.FidoNet> Date: 29 May 91 04:16:11 GMT Sender: Usenet@sunbrk.FidoNet.Org Lines: 33 A few days ago I bought Borlands Turbo C++ for MS-DOS. After some experimenting I found a strange and undocumented behaviour of the kbhit() and getch() functions (unique to TC++ for DOS). I wrote a program that reads from stdin, but, depending on the commandline arguments may use freopen() like freopen(file, "r", stdin) If, after some output to the screen the program has to wait for a user action by while(!kbhit()) /* do nothing */; ch = getch(); /* etcetera */ it reads input from stdin, instead of reading from the keyboard as documented. At the end I decided to use another FILE *stream and use statements like stream = stdin; and freopen(file, "r", stream); I did not try to run the program as a DOS command yet, but I will do so tomorrow, and let you all know. Furthermore, I am curious if this is the right newsgroup to report bugs (or features) like this one. Please let me know. Bert IJff. * Origin: Seaeast - Fidonet<->Usenet Gateway - sunbrk (1:343/15.0)