C Interview Questions and Answers


What should malloc0 do? Return a null pointer or a pointer to 0 bytes?

The ANSI/ISO Standard says that it may do either; the behavior is implementation-defined
Portable code must either take care not to call malloc(0), or be prepared for the
possibility of a null return.

Posted by:Richards