Welcome to The Homework Channel.

First of all, such a function would have to take STRINGS not NUMBERS. Simply because numbers are always represented in binary in a computer.

In short, what you do first is scan the input string left to right, accumulating the numerical value from each digit:

x = 0

position = 0

while ( not at end of inputstring )

{

x = base * x + digitvalue(inputstring[position])

increment position

}

Then you have the input value in X, in whatever representation your computer uses.

Now reverse the procedure in the other base:

position = 0

while x > 0

{

outputstring[position] = makedigit( x modulo newbase )

x = x / newbase

increment position

}

Now you got the converted number, but it's right to left.

Not exactly high tech, is it? Computer Science, Beginner's Course, 3rd homework. Or so. You're welcome.

Figuring out the "digitvalue" and "makedigit" subfunctions (extracting a digit value from a character, and making a digit value into a character, respectively) are left to you. So is understanding why these two don't need to know the base.

regards,

Peter