fopen

fgets

#include <stdio.h>char *fgets(char *str, int num, FILE *stream);

The fgets( ) function reads up to num–1 characters from stream and stores them in the character array pointed to by str. Characters are read until either a newline or an EOF is received or until the specified limit is reached. After the characters have been read, a null is stored in the array immediately after the last character read. A newline character will be retained and will be part of the array pointed to by str.

In C99, str and stream are qualified by restrict.

If successful, fgets( ) returns str; a null pointer is returned upon failure. If a read error occurs, the contents of the array pointed to by str are indeterminate. Because a null pointer will be returned either when an error has occurred
or when the end of the file is reached, you should use feof( ) or ferror( ) to determine what has actually happened.

Related functions are fputs( ), fgetc( ), gets( ), and puts( ).




C(s)C++ Programmer's Reference
C Programming on the IBM PC (C Programmers Reference Guide Series)
ISBN: 0673462897
EAN: 2147483647
Year: 2002
Pages: 539

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net