strange behavior from SUN strtod()

Mike Agostino magostin at procase.UUCP
Wed Jul 20 09:15:00 AEST 1988


I seemed to have discovered a bug in the SUN library function strtod().  Can anyone confirm
this?  Here is a sample program:

#include <stdio.h>
main() {

static char *real = "  1.2x",*p;
double a;
extern double strtod(); 

a = strtod(real,&p);
printf("a = %f\n\n",a);
printf("*p = %c\n\n",*p);
}

	It seems to me that the output of this program should be similiar to:

149 <//c/u/magostin>a.out
a = 1.200000

*p = x

150 <//c/u/magostin>

This output is from Apollo's C compiler which seems to correctly intepret the standard.
The problem w/ the Sun strtod() lies in that the second parameter is not correctly 
passed back.  It should point at the first non-numeric character in the string.  (in this
example the 'x') However, on the SUN the second parameter remains pointing to the beginning
of the string.  Any comments on this behavior?  Have I made a mistake?  Please 
email me, I will post to the net if sufficient response.

thanks for any help

mike agostino
...{hpda,tolerant,cae780}!procase!magostin



More information about the Comp.lang.c mailing list