Re: how to pass float value from argv?



Richard Heathfield wrote:
Sunny said:

<snip>
It would be better to try not to use atoi()/atof().

Agreed.

If you read
the C manual. It clearly says that both atoi() and atof() has been
deprecated by strtol() and strtod()

Which C manual? If you mean the Standard, C&V please. If you mean the man pages, mine don't say any such thing.

Some do, the (Open)Solaris page says:

Calls to atoi() and atol() might be faster than correspond-
ing calls to strtol(), and calls to atoll() might be faster
than corresponding calls to strtoll(). However, applications
should not use the atoi(), atol(), or atoll() functions
unless they know the value represented by the argument will
be in range for the corresponding result type.

--
Ian Collins
.



Relevant Pages

  • Re: Check all errors in code?
    ... The atoi function converts the initial portion of the string ... pointed to by nptr to int representation. ... The atoi function returns the converted value. ... The strtol function returns the converted value, ...
    (comp.lang.c)
  • Re: atoi return
    ... The functions atof, atoi, atol, and atoll need not affect the ... strtolreturns 0 and sets errno to ERANGE. ...
    (comp.lang.c)
  • Re: question
    ... strtod is capable of telling you about errors. ... Use that capability. ... I am just used to using atoi. ... I'll check out strtol. ...
    (comp.lang.c)
  • Re: how to pass float value from argv?
    ... Calls to atoi() and atol() might be faster than correspond- ... ing calls to strtol(), and calls to atoll() might be faster ...
    (comp.lang.c)
  • Re: how to pass float value from argv?
    ... It clearly says that both atoi() and atof() has been ... deprecated by strtol() and strtod ... The man pages on Ubuntu ...
    (comp.lang.c)