Code:
#include <stdio.h>
#include <conio.h>
int infiniteloop(int index);
int main() {
infiniteloop(0);
}
int infiniteloop(int index) {
int ch;
int i4 = index;
while (!_kbhit()) {
i4++;
printf("%d\n", i4);
}
if((ch = _getch()) != 13) {
infiniteloop(i4);
}
return(0);
}
This works now, but I have a dependency on Windows. I'm using Visual Studio 2005 on XP Pro and want to write code that's not OS dependent.
I want to be able to loop numbers, print them to the screen, and stop the loop when I press enter. Is there a way to do it without using _kbhit?
This just seems like something that somebody must have done before but I'm not coming up with anything specifically like this.