Recursion Problem

My problems requires me to take an input number from a text file and a base number from the text file. Then I am converting the first number to the base of the second recursively.
I am having trouble getting the last digit of the converted and I do not know how to store the number so that I can return the number.



#include <iostream>
#include <fstream>
#include <string>
using namespace std;

int baseCase(int input, int base);

// This function will read the values in from the txt file and call the functions needed.
void main()
{
int input, base;
ifstream numbers;
numbers.open("numbers.txt");
numbers >> input >> base;
while (input >=0 && base >= 0)
{
baseCase(input, base);
numbers >> input >> base;
}
numbers.close();
}


//This function will take the input data and convert it to the base case.
int baseCase(int input, int base)
{
if (input > 1000000000)
{
cout << "Decimal number is too big for this program" << endl;
return 0;
}
else if (base > input)
{
cout << (input % base);
return 0;
}

else
{
int number =(input % base);
baseCase(input / base, base);
cout << number;



}
}
Topic archived. No new replies allowed.