Anything related to C or C++ standard library functions gets (C) or std::gets (C++). These functions are used to read a sequence of characters from an input stream and to write it into a character buffer as a string. DO NOT USE THESE FUNCTIONS: they are deprecated, and since C11 gets is no longer part of the standard.
Anything related to C or C++ standard library functions gets
(defined in <stdio.h>
C standard header) or std::gets
(defined in <cstdio>
C++ standard header). These functions are used to read a sequence of characters from an input stream and to write it into a character buffer as a string. There are no constraints on the functions to prevent them writing outside the bounds of the array that is passed.
DO NOT USE THESE FUNCTIONS: they are dangerous and deprecated for security reasons because they are susceptible for easily causing buffer overflow. For more information about why the use of gets
is harmful, consider the link below.
Since C11 (ISO/IEC 9899:2011) gets
has been removed from the C standard library. Annex K of the C standard defines an optional replacement function called gets_s
for backwards-compatibility reasons, but makes the following recommendation to use fgets
whenever possible:
ISO 9899:2011 K.3.5.4.1
Recommended practice
The
fgets
function allows properly-written programs to safely process input lines too long to store in the result array. In general this requires that callers offgets
pay attention to the presence or absence of a new-line character in the result array. Consider usingfgets
(along with any needed processing based on new-line characters) instead ofgets_s
.
Note that gets_s()
is not generally available except on Windows using the Microsoft C library.
See CPPreference.com: