0

How to verify the scanf's input

Hello, i want some advice for the scanf function. The goal of the function is to ask to the "human part" what value does he want to enter, but what if the value does not correspond. For example: int b = 0; scanf("%d", &b); "repond of the human part" -> "hello" the variable "b" is an integer but the input is a string. How to verify if the input is garbage and then ask until the input is correct. I look forward to our answers, thank you

1st Feb 2019, 5:49 PM
Dimitri Felix
Dimitri Felix - avatar
2 Réponses
+ 1
Thank you alot, i did not find any answer for that i didnt think about that.
2nd Feb 2019, 4:05 PM
Dimitri Felix
Dimitri Felix - avatar