fgets
◄Summary► ◄Example► ◄Up► ◄Contents► ◄Index► ◄Back►
────────────────────────────────────────────────────────────────────────────
The fgets function reads a string from the input <stream> and
stores it in <string>. Characters are read from the current stream
position up to and including the first newline character (\n),
up to the end of the stream, or until the number of characters
read is equal to <n>-1, whichever comes first.
The characters read are stored in <string>, and a null character
(\0) is appended. The newline character, if read, is included in
the string.
If <n> is equal to 1, <string> is empty (""). The fgets function
is similar to the gets function; however, gets replaces the
newline character with NULL.
Return Value
If successful, the fgets function returns <string>. It returns
NULL to indicate either an error or end-of-file condition. Use
feof or ferror to determine whether an error occurred.
-♦-