Hi,
I've tried getchar, but it freezes everything that's happening until the user enters input. I want to know how to loop something while the user enters input and then have the program react to the input. Any help would be appreciated. Thanks
Hi,
I've tried getchar, but it freezes everything that's happening until the user enters input. I want to know how to loop something while the user enters input and then have the program react to the input. Any help would be appreciated. Thanks
There is no portable way to do this. You need find the way your OS supports non-blocking input or Asynchronous I/O.
Tim S.
Last edited by stahta01; 01-23-2012 at 03:31 PM.
"...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson
You can use a library like ncurses (pdcurses on Windows) to get non-blocking input. There *are* other options (namely, using functionality from your OS or putting IO into a separate thread) but they are either less portable or more complicated, respectively, than the ncurses route.
Consider this post signed
Thanks, I'll try that.
Edit: unfortunately, my compiler (Dev) doesn't have pdcurses or ncurses. how would I get these files?
Last edited by Isaiah; 01-23-2012 at 03:40 PM.
Public Domain Curses | Free Development software downloads at SourceForge.net
You might do the non-portable way of getche, I have never used it so it might not be the right conio function.
getch() equivalent for Dev C++
Tim S.
Last edited by stahta01; 01-23-2012 at 03:49 PM.
"...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson
thanks again.