Solved

getchar()  problem

Posted on 1997-11-24
3
263 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

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

Title # Comments Views Activity
GIF file bit manipulation for color change 5 107
building a service to accessed via telnet client, want colors ? 4 81
matchUp  challenge 9 92
Path of Workbook 3 59
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

911 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

21 Experts available now in Live!

Get 1:1 Help Now