私は次の方法でintを出力しようとしています:
void the_int(int i)
{
int lenghtOfInt = 0;
int tempValue = i;
while(tempValue >= 1)
{
tempValue/=10;
lenghtOfInt++;
}
int currentDigit;
char string[lengthOfInt];
while(i>9)
{
currentDigit= i % 10;
i = i/10;
char ch = (char)(((int)'0')+currentDigit);
string[lengthOfInt--] = ch;
}
string[lengthOfInt]= (char)(((int)'0')+i);
function(str); //prints the string character by character
}
この関数をi=12で試してみると、à12çが得られます。私は何が間違っているのですか?