#include <iostream>
#include <conio.h>
int main(){
while(true){
printf("Hello World!\n");
}
return 0;
}
The above program will print "Hello World" endlessly. I want that as soon the user presses the "T" key on the keyboard, the program terminates. Any clue on how to do this.......
If I do it like
#include <iostream>
#include <conio.h>
int main(){
char key;
while(true){
printf("Hello World!\n");
key = getch();
if(key=='T' || key=='t'){
break;
}
}
return 0;
}
Then the program will always wait for the user to press a key. I want that the program continues executing without pausing, and as soon as user presses any specific key, then the program terminates.
By the way my operating system is linux (debian) and I'm using gcc.