[comp.lang.c++] BC++ and kbhit

engbert@cs.vu.nl (Engbert Gerrit IJff) (05/29/91)

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.

Engbert.Gerrit.IJff@sunbrk.FidoNet.Org (Engbert Gerrit IJff) (05/29/91)

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)