title: C/C++ casting problems, unsigned char to char
body: <p>i have an unsigned char which i need to convert to char before printf. So the example code goes like this:</p>
  
  <pre><code>   unsigned char y = sample.result;  
     char x = (char)y;  
     printf("%c \n", x);  
  </code></pre>
  
  <p>However, <code>printf</code> does not print <code>x</code> but if i use cout, <code>x</code> prints correctly.I have no idea why so. How to i convert a unsigned char variable to a char? Am i doing it wrong? reinterpret_casting is only for pointer and mine are not pointers. Thanks in advance.</p>
  
  <p><strong>EDIT: Command prompt returns me a smiley face "☺" for the value of sample.result which corresponds to unsigned char 1. And apparently netbeans is unable to print this smiley face. I have no idea how it got translated into a smiley face. Any help?</strong></p>
  
  <p><strong>EDIT 2: I just realized you can't print char x = 1; in netbeans, and printing it in command prompt yields the smiley face. Reasons? :(</strong> </p>