non blocking input
Is there any way to check for input and also let the program continue running. I currently have cin statements but i dont want the program to wait there for input, it has to continue updating.
Ive read about multiple threads but just looking at examples seems over the top for me to currently do.
Thanks for any help.
quote:
I'm not so sure on how to do it in console but I think this might work...
Yup it worked I just needed to try it I guess...Is very simple try this...
#include <stdio.h>#include <conio.h>int main(){ while(1) { if(kbhit()) { char x = getch(); if(x == 27) break; if(x == 'a')printf("A was pressed\n"); //if you want to use arrow keys... if(x == 77) printf("Right\n"); if(x == 75) printf("Left\n"); if(x == 72) printf("Up\n"); if(x == 80) printf("Down\n"); } } return 0;}
[edited by - FtMonkey on September 24, 2003 2:23:52 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement