C++ examples for Data Type:char array
Using strtoul to converts to char based string an unsigned long integer.
#include <iostream> #include <cstdlib> // strtoul prototype using namespace std; int main() //from w w w . j av a 2 s . c o m { unsigned long x; const char *string1 = "1234567abc"; char *remainderPtr; // convert a sequence of characters to unsigned long x = strtoul( string1, &remainderPtr, 0 ); cout << "The original string is \"" << string1 << "\"\nThe converted value is " << x << "\nThe remainder of the original string is \"" << remainderPtr << "\"\nThe converted value minus 567 is " << x - 567 << endl; return 0; }