-
Instantaneous Input
How do you set it up to actively wait for a key press, and then use that key press. Instead of user typing the letter and hitting enter. I just want them to hit the key. Not have to hit enter as well.
I tried
getch()=input;
switch(input)
{
case 'a':
blah blah
case 'b':
blah blah
}
but you still have to hit enter after typing the letter.
Also. how do you do the same thing as above except let them just hit enter to perform a function. I guess i'd need to know the value of the Enter key.
Thanx ahead of time,
Darkflame
-
char a;
a=getch(); //in conio.h
works for some compilers but there is no standard way. What o/s and compiler are you using?
-
I'm running WinMe & using Dec-C++
-
Try this:
#include <dos.h>
char a;
if(kbhit())
{
a = getch();
cout<<a<<endl;
}
-
For Dev C++ you have to include <conio_mingw.h> if you want to use getch() without have the input echoed on screen.
-
In Microsoft Visual C++ you can use:
Get a character from the console without echo (_getch) or with echo (_getche).
int _getch( void );
int _getche( void );
with <conio.h>.