Re: gets() is dead
- From: Tak-Shing Chan <t.chan@xxxxxxxxxx>
- Date: Sun, 20 May 2007 12:00:47 +0100
On Sun, 20 May 2007, Ian Collins wrote:
Tak-Shing Chan wrote:On Sun, 20 May 2007, Ian Collins wrote:That's why they wrap fgets() in a function that checks for error and
Tak-Shing Chan wrote:On Sun, 20 May 2007, Ian Collins wrote:
Charles Richmond wrote:There isn't any good reason to use it.
You do *not* have to "gets()" nasty. I sometimes use bubble sort
too, when I think it is appropriate. I am surprise you would
use so much bandwidth just to disparage me. How about telling
me something I don't know about "gets()" that would convince me
*not* to use it for games or my own "quick and dirty" use.
There's one: simplicity. You don't need to handle the
newlines yourself.
Discarding the last character in a buffer read with fgets() is hardly a
burden.
A good programmer is a lazy programmer.
removes the newline!
For a five-line throw-away program, that would be overkill.
When the entire user base is one person, it might be feasibleSo you'd rather add code to warn the user than remove a newline.
to shift the burden of safety to the user. The programmer needs
only to forewarn the user of the consequences of exceeding the
prescribed line length. If the user ignores this advice, then
the responsibility lies with the user, not the programmer.
In Charles Richmond's case, the user is /also/ the
programmer, so there is no need to add code.
Tak-Shing
.
- Follow-Ups:
- Re: gets() is dead
- From: Richard Heathfield
- Re: gets() is dead
- From: Flash Gordon
- Re: gets() is dead
- References:
- Re: gets() is dead
- From: Charles Richmond
- Re: gets() is dead
- From: Ian Collins
- Re: gets() is dead
- From: Tak-Shing Chan
- Re: gets() is dead
- From: Ian Collins
- Re: gets() is dead
- From: Tak-Shing Chan
- Re: gets() is dead
- From: Ian Collins
- Re: gets() is dead
- Prev by Date: Re: gets() is dead
- Next by Date: Re: The result of ++ is not an lvalue?
- Previous by thread: Re: gets() is dead
- Next by thread: Re: gets() is dead
- Index(es):
Relevant Pages
|
|