我觉得这很奇怪。strtod接受“e”但也接受“d” - 为什么?
尽管strtod在输入字符串中接受'e'作为其中一个字符(准确地说是一个字符),但我发现它也接受'd'。
有人能解释一下吗?
#include <stdio.h>
#include <stdlib.h>
int main()
{
char *s[] = {"1a1", "1e1", "1d1", "1f1"};
char * pEnd;
double d0, d1, d2, d3;
d0 = strtod (s[0],&pEnd);
d1 = strtod (s[1],NULL);
d2 = strtod (s[2],NULL);
d3 = strtod (s[3],NULL);
printf ("::: [%f] [%f] [%f] [%f] \n", d0, d1, d2, d3);
return 0;
}
这可能有助于:http://stackoverflow.com/questions/2555097/reading-ascii-numbers-using-d-instead-of-e-for-scientific-notation-using-c – cnicutar 2011-06-02 15:29:06