Using strtod: convert string to double
#include <iostream>
#include <stdlib.h>
using namespace std;
int main()
{
double d;
char *string = "51.2% are admitted", *stringPtr;
d = strtod( string, &stringPtr );
cout << "The string \"" << string
<< "\" is converted to the\ndouble value " << d
<< " and the string \"" << stringPtr << "\"" << endl;
return 0;
}
Related examples in the same category