C printing of string is resulting in weird characters
<p>I am trying to output an int the following way:</p>

<pre><code>void the_int(int i)
{
     int lenghtOfInt = 0;
     int tempValue = i;
     while(tempValue &gt;= 1)
     {
          tempValue/=10;
          lenghtOfInt++;
     }

     int currentDigit;
     char string[lengthOfInt];
     while(i&gt;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
}
</code></pre>

<p>if i try this function with i = 12 I get à12ç. What am I doing wrong?</p>
