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* is 64 bit and int is 32 bit. so half data will be
lost, and you code will crash. And if you add (int*) cast, it will
suppress the warning message.(You kill the only clue, it’s bad).
continue: So don’t recommend to use (int*) cast at all. Next question is
that malloc actually return void*. Can void* automatically implicit
be 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.