If you are using Win32 with conio.h
available, you can use the usual kbhit()
and getch()
combination:
#include <conio.h>
#include <iostream>
int main(){
for(int i=0;i<100000;i++)
{
std::cout<<"Hi";
if(kbhit() && getch() == 'i'){
break;
}
// other code
}
}