Solved

getchar()  problem

Posted on 1997-11-24
3
259 Views
Last Modified: 2013-12-26
HI, I'm doing a unix programming. However, i get problem when I try to read some input from keyboard. I use "getchar()" to do it, however, the programming is justing waiting there until somebody key in something.  Is there a way to periodly check if there is any key-input in the input-buffer. If there is, then read the key. If not, continue to wait.  I have do this in DOS. However, I don't know how to do it in UNIX.  
0
Comment
Question by:wzou
3 Comments
 
LVL 10

Accepted Solution

by:
rbr earned 40 total points
Comment Utility
In Unix this problem is a little bit complicated. You have to use ioctl and
the read function. Use your manual, and if you are interessted in a programm
working with this send an email to rbr@physik.kfunigraz.ac.at. I'll send you
a demo program.
0
 
LVL 84

Expert Comment

by:ozo
Comment Utility
#include <time.h>
int select(size_t nfds, int *readfds, int *writefds, int *exceptfds, const struct timeval *timeout );

#include <curses.h>
halfdelay(1)

#include <fcntl.h>
fcntl(0, F_SETFL, O_NDELAY);

#include <termio.h>
termio.c_cc[VMIN] = 0;
termio.c_cc[VTIME] = 0;
0
 

Author Comment

by:wzou
Comment Utility
Hi rbr,

Thanks for help. I will appreciate if you could send me the demo . My Email address is wzou@comp.uark.edu.

Best regards!!



0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

771 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

14 Experts available now in Live!

Get 1:1 Help Now