Un altro approccio potrebbe essere il seguente:
#include <iostream>
using namespace std;
int main()
{
char u[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
char v[100];
int dim = 0;
int n;
int base;
cout << "n --> ";
cin >> n;
cout << "base --> ";
cin >> base;
cout << endl << n << "(10) = ";
do
{
v[dim++] = u[n % base];
}
while(n /= base);
for(int i = 0; i < dim; ++i)
{
cout << v[dim - i - 1];
}
cout << "(" << base << ")" << endl;
}