FGETS(3) Library Functions Manual FGETS(3)

fgetsget a string from a stream

#include <stdio.h>

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

The fgets() function reads bytes from stream into the array pointed to by s , until n -1 bytes are read, or a newline character is read and transferred to s , or an end-of-file condition is encountered. The string is then terminated with a null byte.

The fgets() function may mark the st_atime field of the file associated with stream for update. The st_atime field will be marked for update by the first successful execution of , fgets(), , , , , , , or using stream that returns data not supplied by a prior call to or .

Upon successful completion, fgets() returns s. If the stream is at end-of-file, the end-of-file indicator for the stream is set and fgets() returns a null pointer. If a read error occurs, the error indicator for the stream is set, fgets() returns a null pointer and sets errno to indicate the error.

Refer to fgetc(3) .

None.

None.

None.

fopen(3) , fread(3) , gets(3) , <stdio.h> .

Derived from Issue 1 of the SVID.

February 1997 posix.fail