Using atol: convert string to long : Long « Data Type « C++






Using atol: convert string to long

  
#include <iostream>
#include <stdlib.h>
using namespace std;
int main()
{
   long l = atol( "1000000" );

   cout << "The string \"1000000\" converted to long is " << l
        << "\nThe converted value divided by 2 is " << l / 2 
        << endl;
   return 0;
}
  
    
  








Related examples in the same category

1.cout for long intcout for long int
2.Using strtol: convert string to long
3.Using strtoul: convert string to unsigned long