That's not a bug, it's a feature. How else would you be able to determine what comes next when a scanf stops prematurely? If it ate the "failing" character, you could never see what it was. I think the routine was designed on the assumption that the programmer would not be so stupid as to keep trying to scan a chunk of input over & over with the same failing format.