Re: gets() is dead



On Sun, 20 May 2007, Ian Collins wrote:

Tak-Shing Chan wrote:
On Sun, 20 May 2007, Ian Collins wrote:

Tak-Shing Chan wrote:
On Sun, 20 May 2007, Ian Collins wrote:

Charles Richmond wrote:

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 isn't any good reason to use it.

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.

That's why they wrap fgets() in a function that checks for error and
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 feasible
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.

So you'd rather add code to warn the user than remove a newline.

In Charles Richmond's case, the user is /also/ the
programmer, so there is no need to add code.

Tak-Shing
.



Relevant Pages

  • Re: gets() is dead
    ... use so much bandwidth just to disparage me. ... A good programmer is a lazy programmer. ... That's why they wrap fgets() in a function that checks for error and ... So you'd rather add code to warn the user than remove a newline. ...
    (comp.lang.c)
  • Re: gets() is dead
    ... I am surprise you would ... That's why they wrap fgets() in a function that checks for error and ... the responsibility lies with the user, not the programmer. ... So you'd rather add code to warn the user than remove a newline. ...
    (comp.lang.c)
  • Re: Universal "Comment" Character
    ... So far it looks like ONLY a newline beginning "*" works for ALL cases ... Don't you have a son who is a programmer? ... ...Jim Thompson ...
    (sci.electronics.cad)
  • Re: Outputting formatted html from php scripts
    ... David Mackenzie writes: ... newline then the newline will not be output. ... _`\<,_ Analyst / Programmer ...
    (comp.lang.php)