Data Representation

Write a C++ program that takes 3 command line arguments: The program should output the number in the requested base. For example:
prompt> ConvertBase 123 10 8
173
prompt> ConvertBase 123 10 2
1111011
prompt> ConvertBase AA2 16 10
2722
The program must work for any bases upto 16 (not just the common binary, octal, decimal, and hexidecimal bases!).