It\'s not a typo. And for the one who doesn\'t notice, there is a space on the second one, and no space on the first.
It happens to me when i make a homework like this:<
There are three standard format specifiers for the scanf() family of functions that do not automatically skip white space. They are:
%c
%[]
— scan sets%n
All other (standard) format specifiers skip leading white space.
By including the white space before %[]
, you skip leading white space, because a single white space in the scanf()
family format string (outside a scan set) matches zero or more white space characters in the input. Note, in particular, that this means that if you type some blank lines (just hit return), the white space will continue merrily ignoring (more accurately, discarding) the input until a non-white-space character is entered. Only then will scanf()
start processing the scan set.