Scanf expects data of the correct type. If you enter in the wrong data then it fails to work.

Have you tried fgets() (nevermind I just re read the post)

You can try to catch what scanf is returning so if it returns 0 you at least know it failed something along the lines of
Code:
int check = 1;int var = 0;while(check){    check = !scanf("%d", &var);}

fgets(buffer,size,stdin) is your friend - scanf() is not