Hi, all. I do search the forum before raise my problem. I need to convert a string to a double, but the atof() or strtod() is not work. Why? What is wrong with my code?
Here is the output after compiled and run:
main (int argc, char *argv)
char *pr0 = "0.05";
double pr2, pr3;
pr2 = atof(pr0);
pr3 = strtod(pr0, &ptr);
printf("The number from atof() is: %d\n", pr2);
printf("The number from strtod() is: %d\n", pr3);
Anyone can help?
The number from atof() is: -1717986918
The number from strtod() is: -1717986918