title: Difference between static_cast<char*> and (char*)
body: <p>this is my first question :)</p>
  
  <p>I have one pile file, and I have open it like shown below ;</p>
  
  <pre><code>ifstream in ( filename,  ios :: binary | ios :: in ) 
  </code></pre>
  
  <p>Then,  I wish  hold 2 byte data in unsigned int hold ;</p>
  
  <pre><code>unsigned int hold;
  in . read(static_cast&lt;char *&gt;(&amp;hold), 2); 
  </code></pre>
  
  <p>It seems correct to me. However, when I compile it with </p>
  
  <pre><code>g++  -ansi -pedantic-errors -Werror - -Wall  -o main main.cpp 
  </code></pre>
  
  <p>Compiler emits error </p>
  
  <pre><code>error: invalid static_cast from type ‘unsigned int*’ to type ‘char*’ 
  </code></pre>
  
  <p>Actually, I have solved this problem by changing  static_cast with ( char*), that is </p>
  
  <pre><code>unsigned int hold;
  in . read((char*)(&amp;hold), 2); 
  </code></pre>
  
  <p>My questions are :</p>
  
  <ul>
  <li>What is the difference(s) between <code>static_cast&lt;char*&gt;</code> and <code>(char*)</code> ?</li>
  <li>I am not sure whether using <code>(char*)</code> is a safer or not. If you have enough knowledge, can you inform me about that topic ?</li>
  </ul>
  
  <p>NOTE : If you have better idea, please help me so that I can improve my question?</p>