Advertisement

_getch() function in c++

Started by March 13, 2003 09:41 AM
2 comments, last by jarod83 21 years, 8 months ago
I have this folowing code:
  
...
do
{
	ch = toupper(_getch()); //  <-----

	
	if (ch == ''E'')
	{
		...
		...
	}
	...
} while (ch != ''Q'');

  
When the program reaches this line: "ch = toupper(_getch());", it stops until a keyu is pressed. How can I make the do..while-loop run all the time without any breakes, and still be able to see what key is entered, this is the "ch = toupper(_getch());" line. ???
int _kbhit(void) - _kbhit returns a nonzero value if a key has been pressed. Otherwise, it returns 0.
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
Advertisement
Hehe...

I just found out on google.com, but there is another problem I got...

When I want to clear screen in c++ I use clrscr() function or the system("cls") function, but the problem is when clearing screen, the whole screen is cleared. How to "update" the screen only where the character(s) are other(s) but the last one(s).

I guess I'' not that good at english...
You still need to call _getch() after _kbhit() to get the character pressed.

Journal

This topic is closed to new replies.

Advertisement