I have a very short snippet that reads in an integer:
#include int main() { while (1) { int i = 0; int r = scanf(\"%d\",
Sounds like you are not clearing the input buffer and leaving the incorrect char to be scanned over and over. See here: Scanf and loops and scanf not terminating