Path: utzoo!attcan!uunet!taumet!steve From: steve@taumet.com (Stephen Clamage) Newsgroups: comp.std.c Subject: Re: strtol Message-ID: <527@taumet.com> Date: 20 Nov 90 17:05:23 GMT References: Distribution: comp Organization: Taumetric Corporation, San Diego Lines: 20 mattes@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@taumet.com