gets() function is not available in Visual studio 2015 community
if you are looking forward to learn
about
buffer overflow vulnerability
you simply can use it and anther unsafe functions by the fallowing steps
- from the solution explorer right click on the project and choose properties
- navigate to Configuration Properties >> C/C++ >> Advanced
- change
Compile As
value toCompile as C Code (/TC)
- (optional) if you would like to disable the warning just put its warning number in
disable specific warning
Since C11, gets
is replaced by gets_s
. The gets() function does not perform bounds checking, therefore this function is extremely vulnerable to buffer-overflows. The recommended replacements are gets_s()
or fgets()
gets_s(buf);
fgets(buf, sizeof(buf), stdin);
gets
and_getws
are removed from the beginning of vs 2015 because these functions are obsolete.
Alternative functions are gets_s
and _getws_s
.
The gets
function was considered too dangerous (because it can easily cause a buffer overflow), so it was removed from the latest revisions of both C and C++.
You are supposed to use fgets
instead. With that function you can limit input to the size of your buffer.