[haiku-development] Re: Get/calculate size

  • From: Paul Davey <plmdvy@xxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Thu, 29 Nov 2012 09:36:12 +1300

> 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

Other related posts: