strtol
    Stephen Clamage 
    steve at taumet.com
       
    Wed Nov 21 04:05:23 AEST 1990
    
    
  
mattes at azu.informatik.uni-stuttgart.de (Eberhard Mattes) writes:
>Is the behavior of strtol defined in the ANSI standard?
Yes.  Section 4.10.1.5.
>What should
>    strtol ("089", NULL, 0)
>return?
It should return a long zero (0L).  When you pass in a zero for the
"base" parameter, strtol uses the rules in section 3.1.3.2 for
evaluating the number in the string.  Section 3.1.3.2 says an
integer beginning with 0 is an octal constant, and consists only of
the digits 0-7.  Therefore, the 8 is not part of the integer, and
the string is processed as if it were "0".  Strtol ignores trailing
characters which cannot be part of the integer it converts.
-- 
Steve Clamage, TauMetric Corp, steve at taumet.com
    
    
More information about the Comp.std.c
mailing list