I\'ve a small C-program which just reads numbers from stdin, one at each loop cycle. If the user inputs some NaN, an error should be printed to the console and the input pro
Due to the problems with scanf
pointed out by the other answers, you should really consider using another approach. I've always found scanf
way too limited for any serious input reading and processing. It's a better idea to just read whole lines in with fgets
and then working on them with functions like strtok
and strtol
(which BTW will correctly parse integers and tell you exactly where the invalid characters begin).