Mega Code Archive

 
Categories / C / String
 

Convert string to double-precision floating-point value

#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; }