The gets function reads a line from the standard input stream stdin and stores it in buffer. The line consists of all characters up to and including the first newline character ('\n'). gets then replaces the newline character with a null character ('\0') before returning the line. In contrast, the fgets function retains the newline character. _getws is a wide-character version of gets; its argument and return value are wide-character strings.
Security Note: |
|---|
Because there is no way to limit the number of characters read by gets, untrusted input can easily cause buffer overruns. Use
fgets instead.
|
In C++, these functions have template overloads that invoke the newer, secure counterparts of these functions. For more information, see Secure Template Overloads.
Generic-Text Routine Mappings
TCHAR.H routine
|
_UNICODE & _MBCS not defined
|
_MBCS defined
|
_UNICODE defined
|
|---|
_getts
|
gets
|
gets
|
_getws
|