title: Printing hexadecimal characters in C
body: <p>I'm trying to read in a line of characters, then print out the hexadecimal equivalent of the characters.</p>
  
  <p>For example, if I have a string that is <code>"0xc0 0xc0 abc123"</code>, where the first 2 characters are <code>c0</code> in hex and the remaining characters are <code>abc123</code> in ASCII, then I should get </p>
  
  <pre><code>c0 c0 61 62 63 31 32 33
  </code></pre>
  
  <p>However, <code>printf</code> using <code>%x</code> gives me</p>
  
  <pre><code>ffffffc0 ffffffc0 61 62 63 31 32 33
  </code></pre>
  
  <p>How do I get the output I want without the <code>"ffffff"</code>? And why is it that only c0 (and 80) has the <code>ffffff</code>, but not the other characters?</p>