Gets a string of characters from a stream and stores them in an array.
#include <stdio.h> char *fgets ( char *buf, int n, FILE *fp);
(OUT) Points to the array into which the characters are to be stored.
(IN) Specifies the number of characters to read.
(IN) Points to the file to be read.
If successful, returns buf. If the stream is at the end-of-file, returns a NULL pointer and sets the end-of-file indicator on the stream.
If a read error occurs, returns a NULL pointer, sets the end-of-file indicator on the stream, and sets errno to one of the following:
The fgets function gets a string of characters from the file designated by fp and stores them in the array pointed to by buf. The fgets function stops reading characters when end-of-file is reached, or when a newline character is read, or when n-1 characters have been read, whichever comes first. The newline character is not discarded. A null-terminating character is placed immediately after the last character read into the array.
The gets function is similar to fgets except that it operates with stdin; it has no size argument, and it replaces a newline character with the null-terminating character.