I am trying to make a program to change the base of numbers from base 10 to anything they want (from 2-36). the problem arises when i am trying to convert the numbers to a hex format. I have no clue where i should go, the code i have written so far is
Code:
void convert(vector<int>& rev_rems,int base,int num_div,vector<int>& rems)
{
int num;
int rem;
for(num=num_div;num!=0;num/=base)
{
rem=num%base;
rev_rems.push_back(rem);
}
for(rev_rems;rev_rems.size()!=0;rev_rems.pop_back())
{
rems.push_back(rev_rems[rev_rems.size()-1]);
}
}
void hex_convert(vector<int>& rems,vector<int>& rev_hex)
{
for(int hex=rems[rems.size()-1];rems.size()!=0;rems.pop_back())
{
hex=hex-10;
if(hex<0)
{rev_hex.push_back(rems[rems.size()-1]);}
else
{rev_hex.push_back('0'+hex);}
}
}
the converting part works fine, its the hex_convert where i get confused on what to do