Solved

UNIX C equiv. for conio.h

Posted on 1997-10-23
3
705 Views
Last Modified: 2012-06-21
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?
0
Comment
Question by:dpeng
3 Comments
 
LVL 1

Expert Comment

by:ksato
ID: 1255940
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
 
LVL 3

Accepted Solution

by:
Jackie071497 earned 50 total points
ID: 1255941
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
 
LVL 84

Expert Comment

by:ozo
ID: 1255942
There is a getch() in unix, under
#include <curses.h>
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now