title: C++ cout hex format
body: <p>i am a c coder, new to c++.</p>
  
  <p>i try to print the following with cout with strange output. Any comment on this behaviour is appreciated.</p>
  
  <pre><code>#include&lt;iostream&gt;
  using namespace std;
  
  int main()
  {
          unsigned char x = 0xff;
  
          cout &lt;&lt; "Value of x  " &lt;&lt; hex&lt;&lt;x&lt;&lt;"  hexadecimal"&lt;&lt;endl;
  
          printf(" Value of x %x by printf", x);
  }
  </code></pre>
  
  <p>output:</p>
  
  <pre><code> Value of x  ÿ  hexadecimal
   Value of x ff by printf
  </code></pre>