atof code example
Example 1: how to convert a string to a double c++
double new = std::stod(string);
Example 2: atof in c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main () {
float val;
char str[20];
strcpy(str, "98993489");
val = atof(str);//returns the string as a floating point number
printf("String value = %s, Float value = %f\n", str, val);
strcpy(str, "tutorialspoint.com");
val = atof(str);
printf("String value = %s, Float value = %f\n", str, val);
return(0);
}