Using strtod : convert from string « Data Types « C++ Tutorial






#include <iostream>
using std::cout;
using std::endl;

#include <cstdlib>
using std::strtod;

int main()
{
   double d;
   const char *string1 = "51.2 are admitted";
   char *stringPtr;

   d = strtod( string1, &stringPtr );

   cout << d << endl;
   return 0;
}
51.2








2.29.convert from string
2.29.1.Using atof.
2.29.2.Using atoi
2.29.3.Using atol
2.29.4.Using strtod
2.29.5.Using strtol
2.29.6.Using strtoul