what the function that returns the pressed key but do not waits for it?
for a example, i want that the following code writes "bleh" on the screen until i press w
while(1) {
ch = <my wanted function>
if(ch == 'w')
break;
puts("bleh");
}
what the function that returns the pressed key but do not waits for it?
for a example, i want that the following code writes "bleh" on the screen until i press w
while(1) {
ch = <my wanted function>
if(ch == 'w')
break;
puts("bleh");
}
What OS? What Compiler?
Check to see if your compiler supports getch()
umm.. your not completely clear on what your wanting to do...
but try this...
sorry if thats not right... i really dont know C i do C++Code:#include <conio.h> #include <stdio.h> int ch; bool quit; main() { while ( !quit ) { ch = getch(); if ( ch == 'w' ) quit = 1; else { pfintf ("bleh"); } } return 0; }
What is C++?
hey you two guys, thanks for the help, but you didnt understand good, in your example it will wait for a key be pressed and then will print on the screen, also, dont say me getche() or other standards functions, it wont work
i am using DJGPP
See help on kbhit(). Returns 1 if there was a key pressed, else returns 0. If it returns 1, call getch(), which will return the key pressed.