title: C - Reversing an int to an array
body: <p>I'm trying to reverse the digits of an integer.
  To do this I am:</p>
  
  <ol>
  <li>Taking the integer.</li>
  <li>Putting it into a string.</li>
  <li>Putting the string into another string in reverse.</li>
  <li>Converting the reversed string to a proper integer.</li>
  </ol>
  
  <p>I've sort of gotten to step 3, and while it does reverse the string properly, it leaves me with a lot of odd data.
  <a href="https://i.stack.imgur.com/1Pw7y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1Pw7y.png" alt="The Results"></a>
  The top part is just the array lengths to compare.
  What is happening for this odd data?</p>
  
  <pre><code>int ReverseNumber(int Num) {
  //Variables
  int i = 0;
  int j = 0;
  char Number[50];
  char ReversedNumber[50];
  sprintf(Number,"%d", Num);
  
  //Finding Length Of Array
  do{ 
      i++;
  }while(Number[i] &gt; 10);
  //i - 1(Due to Array Length)
  i--;
  
  //Reverseing
  do {
      printf("%d | %d \n",j,i);
      ReversedNumber[j] = Number[i];
      printf("%c\n", ReversedNumber[j]);
      getch();
      i--;
      j++;
  } while (i != -1);
  
  int NumberLength = (strlen(Number) - 1);
  //Printing
  printf("%s\n", Number);
  printf("%s\n", ReversedNumber);
  }
  </code></pre>