That is a long story. In C language, if you forget a header file, what
will happen? (I have add answer to my evernote). In one word, It
will(c99) or will not produce(c89) warning, and compiler will assume
a "implicit int" rule. That is to say, It will think that the function
without prototype(declaring in the header file) just return int type.
continue: if you have code below: you comment stdlib.h. then compiler will
assume that malloc return a int. this code will run on 32 bit computer,
because int and int* have same length. but on some 64 bit computer, int*
must be 64, and int maybe 32. so half data will be lost, and you code
will crash. And if you add (int*) cast, it will suppress the warning
message.(bad).
continue: So Don’t recommend to use (int*) cast at all. Next question
malloc will return void*, Can void* automatically implicit cast to int* or
other pointer type in assignment? the answer is YES.
continue: In C++, int *p = (void *) 0 is not legal any more.(C++ is type
safe language). So in C++ NULL is literal 0. But It produce another
ambiguity problem. So In C++11, we define nullptr to resolve this problem.