GETS(3) Library Functions Manual GETS(3)

getsget a string from a stdin stream

#include <stdio.h>

char *gets(char *s);

The gets() function reads bytes from the standard input stream, stdin(3) , into the array pointed to by s , until a newline is read or an end-of-file condition is encountered. Any newline is discarded and a null byte is placed immediately after the last byte read into the array.

The gets() 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 , , , , , gets(), or using stream that returns data not supplied by a prior call to .

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

Refer to fgetc(3) .

None.

Reading a line that overflows the array pointed to by s causes undefined results. The use of fgets(3) is recommended.

None.

feof(3) , ferror(3) , fgets(3) , <stdio.h> .

Derived from Issue 1 of the SVID.

February 1997 posix.fail