Mega Code Archive

 
Categories / C++ / Data Type
 

Using strtoul

#include <iostream> #include <stdlib.h> using namespace std; int main() {    unsigned long x;    char *string = "1234567abc", *remainderPtr;    x = strtoul( string, &remainderPtr, 0 );    cout << "The original string is \"" << string         << "\"\nThe converted value is " << x         << "\nThe remainder of the original string is \""         << remainderPtr         << "\"\nThe converted value minus 567 is "          << x - 567 << endl;    return 0; }