Question for GCC programmers
Lisa Milne
lisa at ltmnet.com
Sat Oct 9 05:25:48 BST 2010
On Sat, 09 Oct 2010 14:26:31 +1100
David Bowskill <davidbow at tpg.com.au> wrote:
> Thanks Lisa for your reply, my requirement I gather is not that
> unusual. Since you enlightened me on the concepts of 'raw' or
> 'cooked' terminals, I have found several other sources on this as
> follows:
> http://osr507doc.sco.com/en/OSUserG/_How_to_get_a_character.html
> http://stackoverflow.com/questions/421860/c-c-capture-characters-from-standard-input-without-waiting-for-enter-to-be-pre.
> There are others as well. I wish to be able to compile the code to
> run under MSWindows (ugh!) for friends to use, so the solution must
> satisfy this. Thanks again for your invaluable help.
> Regards
> David Bowskill
Hi David,
I believe there are curses/ncurses libraries for windows as well as
Linux/Unix, so again that's one option.
However there is also windows conio.h header, which includes a getch()
and _getch() ( the latter being the reccomended one as the former is
deprecated ) which do what you want (I believe, I rarely code for
windows). In this case you'll need to use preprocessor directives to
ensure only the code for the target OS is compiled:
#ifdef _WIN32
/* do windows specific code here */
#else
/* do Linux/Unix/Posix code here */
#endif
--
Lisa Milne <lisa at ltmnet.com>
More information about the ubuntu-au
mailing list