title: Hexadecimal representation of char read from file
body: <p>Here i want to print hexadecimal representation of char which i read from file:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  
  using namespace std;
  
  int main() {
      ifstream f("inputfile");
  
      char ch;
      f.get(ch);
  
      cout &lt;&lt; hex &lt;&lt; (int) ch &lt;&lt; endl;
  
      f.close();  
      return 0;
  }
  </code></pre>
  
  <p>All inputfile has is one byte <code>0xab</code></p>
  
  <p>The output is: <code>ffffffab</code></p>
  
  <p>But if I add (unsigned char) before ch <code>cout &lt;&lt; hex &lt;&lt; (int) (unsigned char) ch &lt;&lt; endl;</code> i have this output: <code>ab</code></p>
  
  <p>Why is it so? Where does these <code>ffffff</code> from in my first input? And why they are not in the second one?</p>