Everything

fgets


Inputs a string from a stream input/output file.

[Format]

#include <stdio.h>

char *fgets (char *s, long n, FILE *fp);

[Parameters]

s Pointer to storage area to which string is input

n Number of bytes of storage area to which string is input

fp File pointer

[Return values]

Normal: End-of-file: NULL

Otherwise: s

Abnormal: NULL

[Remarks]

The fgets function inputs a string from the stream input/output file indicated by file pointer fp to the storage area pointed to by s.

The fgets function performs input up to the (n–1)th character or a new-line character, or until end-of-file, and appends a null character at the end of the input string.

The fgets function normally returns s, the pointer to the storage area to which the string is input, but returns NULL at end-of-file or if an error occurs.

The contents of the storage area pointed to by s do not change at end-of-file, but are not guaranteed when an error occurs.