[comp.lang.c] Kbhit function under SCO Unix 3.2 Development

root@swatty.UUCP (Larry Krone) (05/23/91)

I have an application that needs to abort on a keypress...

In dos, I can use the kbhit function...Is there an equivalent under
SCO Unix ....If so, what is it???


Thanx,


Larry Krone

joe@proto.com (Joe Huffman) (05/24/91)

root@swatty.UUCP (Larry Krone) writes:

>I have an application that needs to abort on a keypress...

>In dos, I can use the kbhit function...Is there an equivalent under
>SCO Unix ....If so, what is it???

If you were compiling with the Zortech compiler for SCO UNIX it would be
kbhit(), same as DOS.  Library source code is available (for a price...).

See the FAQ in comp.unix.questions or c.u.programmer for some hints.
-- 
joe@proto.com

ronald@robobar.co.uk (Ronald S H Khoo) (05/25/91)

joe@proto.com (Joe Huffman) writes:
> root@swatty.UUCP (Larry Krone) writes:
> >In dos, I can use the kbhit function...Is there an equivalent under
> >SCO Unix ....If so, what is it???
> 
> If you were compiling with the Zortech compiler for SCO UNIX it would be
> kbhit(), same as DOS.  Library source code is available (for a price...).
> 
> See the FAQ in comp.unix.questions or c.u.programmer for some hints.

Also, this is the wrong newsgroup.  Followups are redirected.

But to answer the original question:
For many cases:

	/* cheaper than buying zortech :-) */
	#include <stdio.h>
	int kbhit() { return rdchk(fileno(stdin)) != 0; }


will do, but only under Xenix and Unix SYSVR3.2 and higher, linking
with the -lx library, but this answer is good enough for the poster
of the original question.  Of course, you have to setbuf(stdin, (char *)0);
at the beginning of the program to make this work.
-- 
Ronald Khoo <ronald@robobar.co.uk> +44 81 991 1142 (O) +44 71 229 7741 (H)