Convert string to double-precision floating-point value: how to use strtod
#include <stdio.h>
#include <stdlib.h>
int main ()
{
char str[256];
char *p;
double dbl;
printf ("Enter a floating-point value: ");
gets (str);
dbl = strtod (str, &p);
printf ("Value entered: %lf. Its square: %lf\n", dbl, dbl * dbl);
return 0;
}
Related examples in the same category