Malloc only returns a NULL pointer if it fails. Otherwise, in C (not C++), it returns a void pointer which needs to be cast.