title: Why does C++ require a cast for malloc() but C doesn't?
body: <p>I have always been curious about this - why do in C++ I have to cast return value from <code>malloc</code> but not in C?</p>
  
  <p>Here is the example in C++ that works:</p>
  
  <pre><code>int *int_ptr = (int *)malloc(sizeof(int*));
  </code></pre>
  
  <p>And here is the example in C++ that doesn't work (no cast):</p>
  
  <pre><code>int *int_ptr = malloc(sizeof(int*));
  </code></pre>
  
  <p>I heard that in C, in fact, casting an output from <code>malloc()</code> is a mistake. </p>
  
  <p>Can anyone comment on this topic?</p>