• C

UNIX C equiv. for conio.h

I'm trying to port my DOS code over to UNIX but the only catch is UNIX doesn't have conio.h...specifically kbhit ()
I need a way to just detect 1 char in the buffer...I'm using read (...) but it doesn't seem to work. Any leads?
dpengAsked:
Who is Participating?
 
Jackie071497Connect With a Mentor Commented:
The getch() is only supported by DOS & OS/2.
Under Unix, you can use the getchar() like this :
#include <stdio.h>
main()
{
int ch;
ch = getchar();
}

0
 
ksatoCommented:
Wouldn't using getch() work to read off the keyboard and storing it in a buffer.  When getch() returns can't you assume something fresh is in the buffer to be read?
0
 
ozoCommented:
There is a getch() in unix, under
#include <curses.h>
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.