So I'm trying to convert a number from different bases to 10. I tried debugging and I'm 100% sure that the problem is here : nr[i]=j
; What it does is that it takes the integer j and converts it into ASCII, regardless of the fact that nr[i] is a char array.
What can I do to fix this??
int baza,cifra,nrB10,i,j,x,corect;
char nr[32];
char conversie[36]={'0','1','2','3','4','5','6','7','8','9','10','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
printf("Base between 2 and %d):",BAZA_MAX);
scanf("%d",&baza);
printf("Nr. in base %d: ",baza);
scanf("%31s",nr);
nrB10=0;
corect=0;
x=strlen(nr)-1;
for (i=0;i<=x;i++) {
corect=0;
for (j=0;j<baza;j++) {
if (nr[i]==conversie[j]) {
corect=1;
nr[i]=j;
}
}
if (corect==0) {
printf("Numar gresit!");
break;
}
}
for (i=0;i<=3;i++) {
printf("%c",nr[i]);
}
return 0;