| fgets | Function (tigcc.a)

stdio.h

char *fgets (char *s, short n, FILE *stream);

Gets a string from a stream.

fgets reads characters from stream associated to the structure pointed to by stream into the string s. It does this by calling fgetc repeatedly. The function stops reading when it reads either n - 1 characters or a '\r' (0x0D) character, whichever comes first. fgets retains the newline character at the end of s, eventually translated to '\n' character if the stream is opened in "text" mode (see fopen). A null byte is appended to s to mark the end of the string. On success, fgets returns the string pointed to by s. It returns NULL in a case of error.
Note: fgets is used mainly with files opened in "text" mode. As an example, this command may be useful for reading a text line from a TEXT variable.

Uses: fgetc