gets()

closed account (jvqpDjzh)
Why gets() is deprecated in C++?

And why it has been removed from C standard?
Because it is a poorly-thought, dangerous function.

1
2
3
4
5
6
int main()
{
  char name[ 10 ];

  gets( name );  // User enters "John Jacob Jingleheimer Schmidt"
}
C++14 removes it from C++ too.
closed account (jvqpDjzh)
There's one thing about C++ that I can't really understand why: why a to_string() function hadn't exist before C++11, I can't really understand a thing like that!!!
Because std::to_string was only proposed in 2006: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1982.html
Last edited on
closed account (jvqpDjzh)
Yes.. but it's very strange that many modern high-level languages had already one before, but not C++...
Last edited on
Topic archived. No new replies allowed.