<tt>int fscanf(FILE *stream, char *format, ...)</tt>




Document: The C Standard Library

next int scanf(char *format...)
up Input and Output: stdio.h
gif int printf(char *format...)

int fscanf(FILE *stream, char *format, ...)

fscanf() is more or less the converse to fprintf(): it reads characters from stream and attempts to convert them into "internal" representations of appropriate types, as determined by conversion specifications in the string format. The extra arguments must all be pointer types in this case. Typically, these arguments will simply be the addresses of variables (generated with the & operator) into which the converted values are to be stored. fprintf() thus simply stores each converted value at the location pointed at by each extra argument in turn. Again, it is up to you, the programmer, to ensure that the arguments match the conversion specifications correctly; and again, if they do not, then this will not be automatically detected, and will have entirely unpredictable effects.

The conversion specifications handled by fscanf() are quite similar in format to those handled by fprintf(). They will not be described further here.

The return value from fscanf() is the number of input fields or values successfully scanned, converted, and stored, or EOF if end of file or any error is encountered. In general, it is a very good idea for your programs to check this return value to see that it has the expected value.




Document: The C Standard Library

next int scanf(char *format...)
up Input and Output: stdio.h
gif int printf(char *format...)



McMullin@eeng.dcu.ie
Fri Mar 29 14:35:38 GMT 1996