First, thanks for all the help with my other questions, learning a lot fairly quickly. I read basically when you get an error from input, the error stays until you clear it and enters an infinite loop (this describes EXACTLY the problem I was having). So I'm trying to clear it using clearerr() but I can't seem to figure out what I'm trying to clear. I thought I understood but I don't, I commented out the various combinations I've tried but don't work. The error occurs if I enter something like ff55. If I enter 55lb or 503lb or 4kg the program works fine.
printf("Enter a number between 0-200 followed by it's units: ");
testForEOF = scanf("%d%2s", ¤tNumber, currentUnit);
while (testForEOF != -1)
if (strcmp("lb", currentUnit) == 0 && currentNumber >= 0 && currentNumber <= 200)
else if (strcmp("kg", currentUnit) == 0 && currentNumber >= 0 && currentNumber <= 100)
/* I've tried
testForEOF = scanf("%d%s", ¤tNumber, currentUnit);