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






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

#include <cstdlib>
using std::atol;

int main()
{
   long x = atol( "1000000" );

   cout << x / 2 << endl;
   return 0;
}
500000








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