Solved

UNIX C equiv. for conio.h

Posted on 1997-10-23
3
711 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Microsoft vcsetup.exe and vcssetup.exe 8 422
Converting a float to a string function in c languange 10 206
undefined reference to `bswap_128' 9 161
smtp c source code 7 67
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.

776 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