Re: atoi return



vippstar@xxxxxxxxx wrote:
CBFalconer <cbfalco...@xxxxxxxxx> wrote:
Richard Heathfield wrote:
CBFalconer said:

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.

Not so. gets should never appear in any code. atoi can. One
objective of the C standard is to preserve the viability of old
code.

gets(stdout); is safe I believe, just like atoi("123"); is safe.

No, gets is never safe. Read the literature, or scan the c.l.c
archives. atoi is always safe if you limit the input string to
length 4, or even more according to the value of INT_MAX.

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



Relevant Pages

  • Re: atoi return
    ... it's a left over dinosaur like gets. ... No, gets is never safe. ... atoi is always safe if you limit the input string to ... that there could just as easily be a bug in one of a million places ...
    (comp.lang.c)
  • Re: atoi return
    ... that's too big to hold in an int, ... atoi() can be used safely, ... it's a left over dinosaur. ... Google users: ...
    (comp.lang.c)
  • Re: atoi return
    ... that's too big to hold in an int, ... atoi() can be used safely, ... it's a left over dinosaur. ... is intended to convert a string value into an int value. ...
    (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: atoi return
    ... but why bother when you have strtol available. ... it's a left over dinosaur like gets. ... objective of the C standard is to preserve the viability of old ...
    (comp.lang.c)