exiting a loop by pressing a key

Hello

I have a do-while loop that compares some variables stored in a file with new data captured from a device. What I want to do, is when a certain (or any, it doesn't really matter) key is pressed, the loop ends.
Thanks in advance.
What compiler are you using? I know if you use Borland, their <conio.h> file has a function called kbhit(); You can say, in your loop:
1
2
3
4
if (kbhit()) {
  char c=getch();
  break;
}


Thanks a lot, that is exactly what I needed!
I'm using MSVC++ by the way, so it works there too.
Last edited on
Topic archived. No new replies allowed.