Talk:Gets

From Wikipedia, the free encyclopedia

This article is supported by the Wikipedia:WikiProject C++. Please visit the project page for more details on the project.

With regard to the statement that the use of gets is deprecated, in addition to the injunction on the man page "Never use gets", note that gets is cited as an example of deprecation for reasons of security in the article deprecation. Bill 01:05, 15 March 2006 (UTC)

I agree that gets should never be used, but can you point to an official standard that deprecates it? C99 doesn't. Eric119 01:36, 15 March 2006 (UTC)
It isn't deprecated in an official standard, but the term deprecated doesn't always refer to intended withdrawal from a standard. Bill 01:41, 15 March 2006 (UTC)
Okay, I'll change the article to reflect this. Eric119 01:45, 15 March 2006 (UTC)
That looks good. Bill 02:10, 15 March 2006 (UTC)

[edit] No quick fix?

The critical difference between gets overflows and buffer overflows involving other standard C functions, such as scanf, is that calls to scanf can usually be corrected by changing the format specifier (e.g., changing "%s" to "%20s"). There is no such "quick fix" for gets.

Isn't replacing it with a call to fgets exactly analogous to replacing "%s" to "%20s" in a scanf call? Until somebody can show me otherwise, I've removed these sentences. - furrykef (Talk at me) 14:44, 29 June 2006 (UTC)

Actually, fgets(buffer, sizeof buffer, fp) is different from gets(buffer) in that fgets will always try to store the line-terminating newline character, whereas gets never will. So it's not a drop-in replacement. However, I don't think that fact is important enough to need an explicit mention in the article. --Quuxplusone 08:59, 4 December 2006 (UTC)

[edit] For loop style

I changed the function to use a more natural for loop style. Eric119 06:09, 4 December 2006 (UTC)