Re: atoi return



CBFalconer said:

Bill Cunningham wrote:
"Keith Thompson" <kst-u@xxxxxxx> wrote in message

... snip ...

Even worse, if atoi() is given a string that represents a number
that's too big to hold in an int, it invokes undefined behavior.
For example, there's no telling what atoi("99999999999999999999")
will do; it could crash your program or worse.

I see. Must be a left over dinosaur like gets().

No. gets() is just unsafe regardless. atoi() can be used safely,
but why bother when you have strtol available.

In other words, it's a left over dinosaur. And so is gets(). Therefore,
it's a left over dinosaur like gets(). Which is what he said.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
.



Relevant Pages

  • Re: atoi return
    ... Bill Cunningham wrote: ... snip ... ... that's too big to hold in an int, it invokes undefined behavior. ...
    (comp.lang.c)
  • Re: atoi return
    ... Keith Thompson said: ... that's too big to hold in an int, it invokes undefined behavior. ...
    (comp.lang.c)
  • Re: atoi return
    ... that's too big to hold in an int, it invokes undefined behavior. ... atoi() can be used safely, ... it's a left over dinosaur. ...
    (comp.lang.c)
  • Re: AIG strategy of "interpetation"
    ... bird, nuttin BUT a bird, and its skeleton had absolutely NO dinosaur ... plain old ordinary run-of-the-mill DINOSAUR skeleton that had been ... given fake feathers by a hoaxer. ...
    (talk.origins)
  • Re: Natural selection acts on the individual
    ... of a mountain killing the last dinosaur - an event took place. ... But chance is fair. ... Phenotypic difference is not. ...
    (talk.origins)