The C Programming Language says:
Scanf stops when it exhausts its format string, or when some input fails to match the control specification.
It returns as its value the number of successfully matched and assigned input items.
On end of file, EOF(-1) is returned; note that it is defferent from 0, which means that the next input character does not match the first specification in the format string.
经测试,该scanf这类库函数在不同编译环境中,得到的结果是不一样的。比如在VS2012中,只要能够成功读取一位(或多位),其返回值为1,而非成功读取的个数。即使格式串中有多位,但只成功读取到一位,仍然返回1。因此,其可移植性并不是很好,对吧?