Mega Code Archive

 
Categories / C++ / Data Type
 

Using strtod

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