With the introduction of void * pointers in the ANSI/ISO C Standard, explicitly casting the result of a call to malloc() is no longer necessary and may even produce unexpected behavior if <stdlib.h> is not included.
...
| Code Block | ||
|---|---|---|
| ||
#include <stdlib.h> /* ... */ char *p = malloc(10); |
Exceptions
MEM02-EX1. The return value from malloc() may be cast in C code that needs to be compatible with C++, where explicit casts from void * are required.
...