Mega Code Archive

 
Categories / C / Code Snippets
 

Converts the string into a double value

//Declaration: double atof(const char *str); #include <stdlib.h> #include <stdio.h> int main(void) { char j1[80], j2[80]; printf("Enter first: "); gets(j1); printf("Enter second: "); gets(j2); printf("The sum is: %lf.", atof(j1) + atof(j2)); return 0; } /* Enter first: 1 Enter second: 2 The sum is: 3.000000.*/