2008年1月6日 星期日

fscanf and fgets

reading from file

#include
int fscanf(FILE *stream, const char *format, ... );

pass a FILE pointer as the first argument of fscanf. The second argument is like the first argument of scanf i.e. a string containing format specifiers. Then follows a list variable addresses so that you can store the inputted data.

#include
char * fgets ( char * str, int num, FILE * stream );

Reads characters from stream and stores them as a C string into str until (num-1) characters have been read or either a newline or a the End-of-File is reached

沒有留言: