How could I read input from a user without them having to press enter ( like being able to read the char from getch() ).
Printable View
How could I read input from a user without them having to press enter ( like being able to read the char from getch() ).
use kbhit in a while loop
Please explain how that answers my question.
something like this
I think this would work, if not add a ! infront of kbhit.Code:
while(TRUE)
{
if(kbhit())
{
//take action on the user input here
}
}
This have also been explaind with a bunch of different flavors..search the board for kbhit and you will find a more indepth distcusion about user input.
I need to be able to read what the user put in. (cin without the enter)
It's not a standard function (there's no standard way to do what you're asking), but most compilers include some form of
getch()
in conio.h.
Well, is there a way to read what was just input into the console?
while(TRUE)
{
if(kbhit())
{
switch(whattheyputin)
{etc}
}
}
Yes,
char c;
c=getch();
but this depends on your compiler. Which one are you using?
sigh..... MSVC++
It's probobly a bad thing being in the platform I'm in.
YAY! Works :)
Ok, just one more question. The program recognizes the arrow keys, but is it reading them as what they are? Should I use the assigned ASCII symbols to identify them?
Solved.