On Sun, 18 Jan 2004 17:53:57 +0000, Dave <dm*****@nospam.com> wrote::
Hey all,
Is there a function already within ANSI C that waits for character input
until a key is pressed? I know getchar() but, of course, even that waits
for a carriage return before the code moves on...
Thanks
Dave
No. Not in ANSI or ISO C. If you're looking for something to deal
with the old "Press the any key" type situation, you'll have to step
outside of ANSI or ISO C.
On winDOS platforms, *most* compilers have these functions in the
*non-standard* conio.h header. *most*, because some compilers won't
have it at all, and some will have it as a part of some other header.
getch();
or
getche(); // if you want to echo the keypress' character equivalent
// to stdout
If you want something more portable, ncurses has similar functions
(also similarly named). Of course, you still wouldn't be dealing
strictly with standard C, as you'd be using an external library.
----------------------------------------
Thanks,
MCheu