The trick to working with different bases is this: Conversion is done only during input/output. Once the number exists as a C++ integer, the base doesn't matter. The integer is going to be stored in binary. By default, C++ automatically assumes that input/output are decimal. Hex and octal are also built-into cin and cout.
There is a standard C function called strtol() which can convert a string representation in any base to a type-long. There is no standard function to convert the long back to a string, but the Microsoft compiler has _itoa().
I'm having trouble on how to accomplish this. My first though was to handle each of the last 4 characters individually, increment the ones digit from 0-Z, then increment the tens digit and so on, however, that seems very not efficient.
In any case, you will need to separate the last four digits, because the full 6-digit "number" is a hybrid of decimal and base-36.
Code fragment...
Code:
int Base, x ;
char InputString[40];
char OutputString[40]; // For itoa() [Microsoft only]
char *pEnd = NULL; // Required for Strtoul()
cout << "Base? (2-36, 0 to exit) " ;
cin >> Base;
if(!Base)
return 0;
cout << "Number? ";
cin >> InputString;
x = (int)strtol(InputString, &pEnd, Base); // String to long
//*** MICROSOFT ONLY - NOT ANSI C++ ******************************
// Comment-out this section if it causes an error on your compiler
_itoa(x, OutputString, Base);
cout << "\t" << OutputString << "\t\t Base-" << dec << Base << endl;
//*** MICROSOFT ONLY - NOT ANSI C++ ******************************
cout << "\t" << dec << x << "\t\t Decimal" << endl;
cout << "\t" << oct << x << "\t\t Octal" << endl;
cout << "\t" << hex << x << "\t\t Hex" << endl;