// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
#include <iostream>
#include <string>
#include <cstring>

using namespace std;

string xitoa(int v, char *digits)
{
   int radix = strlen(digits);
   string res = "";
   int tmp = v;
   while(tmp>0)
   {
      res = digits[tmp%radix] + res;
      tmp = tmp / radix;
   }
   return res;
}

int main()
{
   cout << xitoa(14,"0123456789ABCDEF") << endl;
   cout << xitoa(22,"0123456789ABCDEF") << endl;
   return 0;
}
