Using atof: convert string to double
#include <iostream> #include <stdlib.h> using namespace std; int main() { double d = atof( "99.0" ); cout << "The string \"99.0\" converted to double is " << d << "\nThe converted value divided by 2 is " << d / 2.0 << endl; return 0; }