scanf return number of variables it successfully filled with info - it has nothing to do with format types - only number of formats is important
Possible return values areCode:scanf("%d %*s %c", &num, &ch)
EOF - is end-of-file reached on input stream
0 if num cannot be read using first format (%d in the sample)
1 if num was read but second parameter was failed to read (%*s is ignored and does not affect the return value at all)
2 if both variables were filled successfully
if you have more format specifiers in the string and more variables - return value can be bigger - till the number of vars passed.
so in most cases the reasonable way to call scanf
The only exception I know is %n specifier - that does not counts - so its variable should not be used in the number_of_variables countCode:if(scanf(format_string, variables) == number_of_variables) { //handle sucess } else { //handle failure }