[haiku-development] Re: Get/calculate size

  • From: looncraz <looncraz@xxxxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Wed, 28 Nov 2012 14:11:37 -0800

On 11/28/2012 12:36, Paul Davey wrote:

    The output shows that you have "too few arguments". which isn't
    surprising considering the odd setup of strtol or stroll.

    If your string is NULL-terminate (character \0) you can pass NULL
    as the second parameter, otherwise it needs to point to the
    address of the last character for consideration in the string (say
    that five times fast ;-))


This is incorrect, the second parameter has nothing to do with determining the length of the string and the input string must always be NULL terminated as it is a C string. The second parameter serves a different purpose, if this value is not NULL strtoll will store in it the address of the first invalid character it encountered in the string, basically it tells you where it stopped converting the string to a number, this is useful for telling if the whole string was converted or how much of it was interpretable as a number.

Paul

Hrm, that does make more sense. Google search, FTL... Sorry for spreading mis-info!!

I always used atol anyway ;-)

--The loon

Other related posts: