title: little endian to big endian in C
body: <p>I have an unsigned int array called hex_values which contains numbers. For example:
  The size of array is 5 and it contains this nubmers:</p>
  
  <pre><code>830C 830C 830C 830C 830C
  </code></pre>
  
  <p>What I need to do is to show them as big-endian values:</p>
  
  <pre><code>0C83 0C83 0C83 0C83 0C83
  </code></pre>
  
  <p>For coverting <code>830C</code> to <code>0C83</code> I used this function :</p>
  
  <pre><code>unsigned int little_big(unsigned int little)
  {
      return((little&amp;0xff)&lt;&lt;24)+((little&amp;0xff00)&lt;&lt;8)+((little&amp;0xff0000)&gt;&gt;8)+      \
                                                               ((little&gt;&gt;24)&amp;0xff);
  }
  </code></pre>
  
  <p>The problem is , that if the first character of number is a zero, then printf will not show that zero ... Is there any way to fix it ? </p>
  
  <h2>THX for any help ...</h2>
  
  <p>edit :</p>
  
  <p>Ok i have now another problem ... For example i have an array of size 5 which contains 5 values lets say 830C 830C 830C 830C 830C ... I have 2 functions (the first which is mentioned in my first post). The second function has this definition <br></p>
  
  <pre><code>void show_big(unsigned int * pt, unsigned int numbers)
  </code></pre>
  
  <p><code>{</code>
      <code>&lt;br&gt;unsigned int hex_b, hex_l;</code></p>
  
  <pre><code>printf("\n");
  
  for (unsigned int i = 0; i &lt; numbers; i++)
  {
      hex_l = *(pt + i);
      hex_b = little_big(hex_l);
  
      printf("%04X", (hex_b &gt;&gt; BITS));
  }
  </code></pre>
  
  <p><code>}</code>
  <br> I am calling this function with this parameters show_big(hex_values, numbers);
  // hex_values is the name of the array with 5 numbers and numbers is 
  only a number which represent how many values has the array ... Problem is , if the array contains more values than 1 then show_big function wont show those numbers in big endian correctly (0C83 0C83 ...)... I have really no idea why ... If it is necessary i can past here full code ... THX for any help. </p>