| Defined in header |
char *gets( char *str );
|(removed in C11)|
char *gets_s( char *str, rsize_t n );
| (since C11) |
stdininto the character array pointed to by
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. The newline character is discarded but not stored in the buffer.
stdinuntil a newline is found or end-of-file occurs. Writes only at most
n-1characters into the array pointed to by
str, and always writes the terminating null character (unless str is a null pointer). The newline character, if found, is discarded and does not count toward the number of characters written to the buffer.
nis greater than
stris a null pointer
n-1characters to the buffer.
gets_sfirst finishes reading and discarding the characters from
stdinuntil new-line character, end-of-file condition, or read error before calling the constraint handler.
gets_sis only guaranteed to be available if
__STDC_LIB_EXT1__is defined by the implementation and if the user defines
__STDC_WANT_LIB_EXT1__to the integer constant 1 before including
|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
stdin. If the failure has been caused by some other error, sets the error indicator (see
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.
gets_s() are the recommended replacements.
| reads formatted input from
| gets a character string from a file stream
| writes a character string to a file stream
(dynamic memory TR)
| read from a stream into a automatically resized buffer until delimiter/end of line
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.