🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #2015

Re: strtol

#2015
From: Stephen Clamage
Date: Tue, 20 Nov 1990 17:05
20 lines
1064 bytes
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
Technical Details
Message-ID: <527@taumet.com>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!taumet!steve
References: <MATTES.90Nov19122748@azu.informatik.uni-stuttgart.de>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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: <MATTES.90Nov19122748@azu.informatik.uni-stuttgart.de>
Distribution: comp
Organization: Taumetric Corporation, San Diego
Lines: 20