Can someone help me to make my function getbase2 to work? It needs to return a string value.
#include<stdio.h>
char GetBase2(int iBase, int iNumber);
int main()
{
int i;
int number;
printf("Enter number: ");
scanf("%i", & number);
printf("Enter base: ");
scanf("%i", & i);
printF("Conversion: %s\n",GetBase2(i,number));
}
// Base 11 upwards conversion function
char GetBase2(int iBase, int iNumber)
{
char iResult;
int Result[64];
int Index = 0;
char BaseDigit[32] =
{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C',
'D', 'E', 'F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V'};
if (iBase>32)
iResult = '0';
//Base conversion starts
while (iNumber != 0)
{
Result[Index] = iNumber % iBase;
iNumber = iNumber / iBase;
++Index;
}
//Back up to the last entry in the array
--Index;
//Prints backwards to get the right result
for (;Index>=0;Index--)
iResult = iResult + BaseDigit[Result[Index]];
return iResult;
}