12345678
int main() { while((kbhit() && getch() != 'a') //only breaks when user presses 'a' { //main code here } return 0; }