stdin
stream. More secure versions of these functions are available; see gets_s, _getws_s.buffer
is NULL, these functions invoke an invalid parameter handler, as described in Parameter Validation. If execution is allowed to continue, these functions return NULL and set errno to EINVAL
.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.fgets
instead.TCHAR.H routine | _UNICODE & _MBCS not defined | _MBCS defined | _UNICODE defined |
---|---|---|---|
_getts | gets | gets | _getws |
Routine | Required header |
---|---|
gets | <stdio.h> |
_getws | <stdio.h> or <wchar.h> |
[ISO/IEC 99] | ISO/IEC. ISO/IEC 9899 Second edition 1999-12-01 Programming languages — C. International Organization for Standardization, 1999. |
[ISO/IEC 05] | ISO/IEC. ISO/IEC TR 24731 Extensions to the C library -- Part 1: Bounds-checking interfaces. International Organization for Standardization, 2005. |