C error using the function atof, changing a string to a double

136 views Asked by At

I´m learning to use these functions that change a string to an int or double, but atof doesn´t work for me.

char cadena[20]="3.1416";
double x=atof(cadena);
printf("%g",x);

I have this simple code, but the output of x is 7.73471e+006. Why? Atoi works fine. I´m using mingw compiler, if that could be the error.

0

There are 0 answers