Defined in header
char *gets( char *str );
char *gets_s( char *str, rsize_t n );
| (since C11)
struntil a newline character is found or end-of-file occurs. A null character is written immediately after the last character read into the array.
struntil new-line character, end-of-file condition, or read error. A null character is written immediately after the last character read into the array, or to str if no characters were read.
nis zero or is greater than RSIZE_MAX, a null character is written to str but the function reads and discards characters from stdin until new-line character, end-of-file condition, or read error.
n-1characters have been read, continues reading and discarding the characters from stdin until new-line character, end-of-file condition, or read error.
gets_sfunction is an extension and is optional. It is guaranteed to be present only if __STDC_LIB_EXT1__ is defined.
|str||-||character string to be written|
str on success, NULL on failure.
If the failure has been caused by end of file condition, additionally sets the eof indicator (see feof()) on stdin. If the failure has been caused by some other error, sets the error indicator (see ferror()) on stdin.
gets() function does not perform bounds checking, therefore this function is extremely vulnerable to buffer-overflow attacks. It cannot be used safely (unless the program runs in an environment which restricts what can appear on
stdin). For this reason, the function has been deprecated in the third corrigendum to the C99 standard and removed altogether in the C11 standard. fgets() and
gets_s() are the recommended replacements.
| reads formatted input from stdin, a file stream or a buffer |
| gets a character string from a file stream |
| writes a character string to a file stream |
C++ documentation for gets