excluding the first one,it stores the count of the total number of characters entered from the console,including the newlines (Enter keys)
You are misinterpreting that. The scanf
s do not consume the final newlines used to send the input to the programme, therefore the newline is left in the buffer to be consumed by the next scanf
. All but the first scanf
consume the newline from the previous input as the first character.
The first scanf
consumes the eight digits plus the three newlines between the four numbers, that makes 11 characters.
The second consumes the newline from after the fourth number read in the first scanf
, plus the two digits, makes 3 characters.
The third: newline, three digits, newline, two digits: 7 characters.
The fourth: newline, four digits: 5 characters. (then newline + 2 digits for b
)
By the way, your quote
The number of characters of the format string already processed is stored in the pointed location.
is incorrect, it's not the number of characters of the format string, but the number of characters read from the input stream:
The corresponding argument shall be a pointer to signed integer into which is to be written the number of characters read from the input stream so far by this call to the fscanf function.