Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!uwm.edu!lll-winken!aunro!alberta!edson!news From: eric@ee.ualberta.ca (Eric Norum) Newsgroups: comp.sys.next Subject: Yet another bug in the NextStep 2.0 C library. Keywords: strtod Message-ID: <1991Apr6.212435.4876@ee.ualberta.ca> Date: 6 Apr 91 21:24:35 GMT Sender: news@ee.ualberta.ca Reply-To: eric@ee.ualberta.ca (Eric Norum) Organization: University of Alberta Electrical Engineering Lines: 32 Consider the following program fragment: #include #include . . char *cp, *ptr; double x; . . cp = "trash" x = strtod(cp, &ptr); From the description of strtod: If the value of ptr is not (char **)NULL, the variable to which it points is set to point at the character after the last number, if any, that was recognized. If no number can be formed, *ptr is set to str, and zero is returned. The strtod supplied with NextStep 2.0 does not behave as expected. It returns a zero and `ptr' is set to point at the '\0' at the end of the `trash' string indicating a valid number was converted. This is most annoying. I use strtod instead of atof because strtod is supposed to return an indication of invalid data. Has anyone got a fix for this? -- Eric Norum Dept. of Electrical Engineering eric@ee.ualberta.ca University of Alberta Edmonton, Canada. phone: (403) 492-4626