is there a way to read from keyboard without breaking a program in C.
meaning if I use getchar the prog waits for new input from the keyboard but I want the program to be executed until it gets a stop character. I know I can use multi threading but is there s tutorial on something simpler?
Name:
Anonymous2010-10-05 6:57
hey
use getchat nonblocking. But that can be tricky, since judging but your post you do not know how to do it?
Name:
Anonymous2010-10-05 7:18
On unix-like systems:
man fcntl to set NON BLOCKING on fd 0.
or use select() to check for available data
Name:
Anonymous2010-10-05 7:26
OP:
my program is not read file or anything else, I get some data from a micro controller and feed it back some acsii characters, I want the program to run all the time until stop key is pressed.
Everything else is done I just need to see how to make the loop non blocking until event
>>4
Read the thread. Then go back to India, code monkey.
Name:
Anonymous2010-10-05 8:15
I can't think of any solution, really, except your suggestion of using threads. If this was embedded programming, I'd simply keep polling the pin the button was connected to, but I don't know if it's even possible to poll the keyboard on a PC. At a guess, I'd say that would be OS specific. It sure isn't anywhere in the C standard, but I'm reasonably sure a solution could be found somewhere in POSIX, not that I'd know where to look.