I expect to endptrpoint to the same meaning with both c strtod()and c strtold(). But they are different. I suspect that I am strtold()wrong. OTOH, this may be the case when the specification is not clear and any result is acceptable.
Is this an error (and with which function) or an undefined / unspecified behavior?
Usage: gcc \ x86_64-pc-cygwin \ 4.8.3
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
int main(void) {
char *s = "123ez";
char *endptr;
double d = strtod(s, &endptr);
printf(" double %f '%s'\n", d, endptr);
long double ld = strtold(s, &endptr);
printf("long double %Lf '%s'\n", ld, endptr);
return 0;
}
Output:
double 123.000000 'ez'
long double 123.000000 'z'
[change]
gcc comand gcc -I"C:\cygwin64\lib\gcc\x86_64-pc-cygwin\4.8.3\include" -O0 -g3 -Wall -c -fmessage-length=0 -std=c99 -MMD -MP -MF"string_fp.d" -MT"string_fp.d" -o "string_fp.o" "../string_fp.c"
GCC 4.9.2
source
share