title: Why does the compiler assume that malloc returns an int?
body: <p>I'm aware that in C it's best practice to never cast the return value of <code>malloc()</code>. I've read that the compiler assumes that <code>malloc()</code> returns an int if you don't include <code>stdlib.h</code>. Of course it would produce an error if you tried to implicitly assign an int to something that's not an int, but that error could be covered up by an explicit cast -- hence the danger of explicitly casting <code>malloc()</code>.</p>
  
  <p>For any function I've created, if the function doesn't exist then the compiler will tell me so. Why does the compiler assume that <code>malloc()</code> returns int even if you haven't included <code>stdlib.h</code>? Shouldn't <code>malloc()</code> just remain undefined until you include <code>stdlib.h</code>?</p>