From 1262296836982763599
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,2622b74be65d448c
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2001-03-05 20:06:02 PST
Path: supernews.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!dispose.news.demon.net!news.demon.co.uk!demon!mail2news.demon.co.uk!not-for-mail
From: Jack Klein <jackklein@spamcop.net>
Newsgroups: comp.std.c++
Subject: Re: strtod
Date: Tue,  6 Mar 2001 04:03:03 GMT
Organization: AT&T Worldnet
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
Message-ID: <2ln8at4cb7ftqkbgatakpgsclfcrcj5rs0@4ax.com>
References: <980cm3$1bqu$1@stargate1.inet.it>
X-Trace: mail2news.demon.co.uk 983851387 mail2news:6203 mail2news mail2news.demon.co.uk
X-Complaints-To: abuse@demon.net
X-Mail2News-Path: news.demon.net!mulga.cs.mu.oz.au
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-Newsreader: Forte Agent 1.8/32.548
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Date: Tue, 06 Mar 2001 03:50:42 GMT
Lines: 54
Xref: supernews.google.com comp.std.c++:3748

On Mon,  5 Mar 2001 16:28:53 GMT, "Mycroft Holmes"
<holmes@technologist.com> wrote in comp.std.c++:

> Two questions:
> 
> 1] is the function "double strtod(const char* strng, char ** stopchar)"
> strictly standard c++?
> 
> 2] assuming 1 is true, is it standard to "work in place" passing stopchar =
> &strng ?

As others have said, you can do this but if you do you lose one of the
valuable properties of the strto... functions.  That is the ability to
easily tell the difference between unconvertible data or an actual
text representation that evaluates to 0 (or 0.0).

Consider:

char *endptr;

char data [/*some size*/];

double d;

/* some code to get input into data */

d = strtod(data, &endptr);

if (d == 0.0)
{
   if (endptr == data)
   {
       // output invalid data entered message
   }
   else
   {
       // data actually says "0"
   }
}

If you don't keep the original pointer around, there is no way to tell
the difference.

-- 
Jack Klein
Home: http://JK-Technology.Com

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]
[ Note that the FAQ URL has changed!  Please update your bookmarks.     ]



