code show as below
#include<stdio.h>
int main(){
char* s = "123.3";
double d = atof(s);
printf("%lf\n", d);
return 0;
}
The result is always 0.000000, not 123.3, why?
迷茫2017-07-05 10:47:54
Because you didn’t include stdlib.h ( ゜ロ゜)”
This is a hidden pit. Because you did not include the header file, there is no function declaration. Without a function declaration, the default return value of the library function is int type.
If you add -Wall when compiling, it will clearly tell you that it is not declared.