Solved

getchar()  problem

Posted on 1997-11-24
3
267 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
ID: 1295679
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
ID: 1295680
#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
ID: 1295681
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to create frequencies of a variable from SAS dataset? 10 125
repeateFront java challenge 31 92
repeatSeparator  java  challenge 13 57
either24  challenge 19 96
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

806 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