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

  1. from the solution explorer right click on the project and choose properties
  2. navigate to Configuration Properties >> C/C++ >> Advanced
  3. change Compile As value to Compile as C Code (/TC)
  4. (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.