Si basa su come funziona la fscanf, nella documentazione

http://www.cplusplus.com/reference/cstdio/fscanf/

troverai

Return Value

On success, the function returns the number of items of the argument list successfully filled.