We all know the dangers of gets.

It is also on the way out in C11.

That makes me wonder: how did it ever get into the standard to begin with? Weren't the problems with it obvious at the time of standardization?

  • recommended reading: On discussions and why they don't make good questions
    – gnat
    Nov 26 '15 at 4:40
  • Standardized... when? getstring with the same functionality existed in B. And something similar existed in BCPL.
    – user40980
    Nov 26 '15 at 4:48
  • 3
    Things were a lot different in 1972. Nov 26 '15 at 5:53
  • The tendency has seemed to be to create a second method with a prefix in front, as to not break old code, for example wcprintf rather than just printf for a wide-character version. So compatibility seems to hold more importance in C++ than forcing usage of more proper methods.
    – Neil
    Nov 26 '15 at 7:29
  • @gnat I'm sorry, but how is this supposed to be a discussion? Nov 26 '15 at 9:15

gets was invented at a time when there were no millions of malicious hackers trying to steal your financial data via the internet. There was no internet to speak of. People didn't put their entire personal lives on computers. Only highly paid specialists were ever supposed to have access to digital computers at all.

Briefly, the threat-countermeasure trade-off was totally different in 1972 - so different that what seems like an incredible oversight today was more like a hasty but ultimately inconsequential pragmatic choice of leaving out error checking.

  • Also, at that time, computer resources where scarce and costly. So perhaps passing an additional argument was not worth the trouble. Nov 26 '15 at 7:27

Not the answer you're looking for? Browse other questions tagged or ask your own question.