Mega Code Archive

 
Categories / C++ Tutorial / Data Types
 

Using strtol

#include <iostream> using std::cout; using std::endl; #include <cstdlib> using std::strtol; int main() {    long x;    const char *string1 = "-1234567abc";    char *remainderPtr;    x = strtol( string1, &remainderPtr, 0 );    cout << x << " " << remainderPtr << " " << x + 567 << endl;    return 0; } -1234567 abc -1234000