How could I read input from a user without them having to press enter ( like being able to read the char from getch() ).
How could I read input from a user without them having to press enter ( like being able to read the char from getch() ).
"If you tell the truth, you don't have to remember anything"
-Mark Twain
use kbhit in a while loop
Please explain how that answers my question.
"If you tell the truth, you don't have to remember anything"
-Mark Twain
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)
"If you tell the truth, you don't have to remember anything"
-Mark Twain
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}
}
}
"If you tell the truth, you don't have to remember anything"
-Mark Twain
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.
"If you tell the truth, you don't have to remember anything"
-Mark Twain
YAY! Works
"If you tell the truth, you don't have to remember anything"
-Mark Twain
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?
Last edited by CodeMonkey; 03-14-2002 at 05:48 PM.
"If you tell the truth, you don't have to remember anything"
-Mark Twain
Solved.
"If you tell the truth, you don't have to remember anything"
-Mark Twain