[SOLVED] getch(); any other way to read the data

Status
Not open for further replies.

Raveesh

Member level 2
Joined
Feb 6, 2011
Messages
42
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,564
Hi,

I Need a some way to read a char from console , the problem with getchar() is, it waits for the user to enter some char on the console and returns that char ..
But in my application I want like, my program should be doing something and after sometime it reads whether the user entered anything at the console or not, if he has entered annthing reed that char otherwise again do something ,, this will be in continuous loop ..
is there anyway to do this...?
regards
 

what platform are you working on, e.g. a PC or microcontroller.
If a microcontroller you can write a functions that polls the UART receiver buffer flag to check if a character has arrived, e.g. for a PIC24F128GA010
Code:
// if character is available return true else false
char UART2IsPressed()
{
    if(IFS1bits.U2RXIF == 1)
        return 1;     // character ready
    return 0;         // nothing
}
 

Hi,
I just want to do this on PC, in DOS mode... using turbo c /Devc compiler ...
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…