title: Copying char array and printing hex from copied array gives error
body: <p>I was trying a basic program to copy elements form one array to another. The source array is having more elements. While copying elements from source to destination i only copy few elements from source array. </p>
  
  <p>My source array contains some hex value.</p>
  
  <p>As i am printing the destination array in hex form the last element is different. i.e that elements unknowingly adds up <code>ffffff</code></p>
  
  <p>Here is the sample program</p>
  
  <pre><code>void String_Copy(char *src, char *dest, int length)
  {
      for (int i=0; i&lt;length; i++)
      {
          dest[i] = src[i];
      }
  }
  
  int main(void)
  {
      char firstStr[] = {0x01,0x03,0x02,0x13,0x88,0xB5,0x12};
      char secStr[5];
  
      String_Copy(firstStr,secStr,5);
  
      for (int i=0;i&lt;5;i++)
      {
          printf("%02x ",secStr[i]);
      }
  
  }
  </code></pre>
  
  <p>Here i want to copy only five elements and print the output.</p>
  
  <blockquote>
    <blockquote>
      <p>Expected Output: 01 03 02 13 88</p>
      
      <p>Getting Output: 01 03 02 13 ffffff88</p>
    </blockquote>
  </blockquote>
  
  <p>Where are these <code>ffffff</code> are coming from???</p>
  
  <p><a href="https://i.stack.imgur.com/9VUFR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9VUFR.png" alt="enter image description here"></a></p>
  
  <p>What is happening behind the scene?????</p>
  
  <p>Thanks in advance</p>