I am trying to produce a function as follows:
wait for a key. If the key matches a key found in a string, return the value, else discard the key and wait for another.
The idea is that i want to be able to wait and respond to single-key presses on a scheme, and have a function to handle this.
So i wrote the function
int keywait(char keys)
where currently keys is a string representing the ASCII values of the keys that can be returned.
So printf("%c", keywait("abcde")) should make a, b, c, d, or e print on the screen when pressed, but no other key.
The function works great -- albeit a couple dilemas.
First, the keys are echoed on the screen during the function.
Second, stdin waits until enter is pressed to return the next key.
These problems i know as a fact are caused by the fgetc function -- which happens to echoe characters and won't start returning characters until a whole line has been typed. I need a function to replace fgetc.
Is there some function in the standard C library that simply checks if a key has been pressed and returns the key, not echoing, and not waiting for the next line to start returning keys?
Any and all help is greatly appreciated. Thanks!!
Jakykong (Jack Mudge)[email protected]