Re: atoi return



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.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.
.



Relevant Pages

  • Re: atoi return
    ... Keith Thompson said: ... that's too big to hold in an int, it invokes undefined behavior. ...
    (comp.lang.c)
  • Re: function
    ... Bill Cunningham wrote: ... snip about styles ... ... Ok I'll try this method and see if I can become consistent using it ... int main{ ...
    (comp.lang.c)
  • Re: for and arrays
    ... Bill Cunningham said: ... int main{ ... Hum. ...
    (comp.lang.c)
  • Re: atoi return
    ... snip ... ... that's too big to hold in an int, it invokes undefined behavior. ... it's a left over dinosaur. ...
    (comp.lang.c)
  • Re: doubles and ints
    ... Bill Cunningham wrote: ... int main { ... exactly what we tell them to, even if it makes no sense: the trick ...
    (comp.lang.c)