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