I am still relatively new to C programming and have come across an error I haven't seen before. I have wrote a program that takes in two ints and converts the first into its respective form of radix based on the second input. I am not asking how to solve the problem I'm just asking where I went wrong to receive this error. I have done some research and know that segmentation faults have to do with pointers and I have played around with mine and have had no luck on getting rid of this error. Any help would be much appreciated!
#include<stdio.h>
void decimalToRadix(int d, int r, char *toRadix);
int main(void){
int decimal, radix;
char toRadixForm[100];
printf("Enter a decimal number: ");
scanf("%d",&decimal);
printf("Enter radix number: ");
scanf("%d",radix);
decimalToRadix(decimal, radix, toRadixForm);
puts("");
return 0;
}
void decimalToRadix(int decimal, int radix, char *toRadix){
int result;
int i=1,x,temp;
result=decimal;
//will loop until result is equal to 0
while(result!=0){
//get the remainder
temp=result%radix;
//if<10 add 48 so character format stored values are from 0-9
if(temp<10)
temp=temp+48;
//if greater that or equal to 10 add 55 to it stores values A-Z
else
temp=temp+55;
toRadix[i++]=temp;
result=result/radix;
}
printf("The value of the number you entered, %d, to radix form is ", decimal);
for(x=i-1; x>0; x--){
printf("%c", toRadix[x]);
}