Interview Questions

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

C Interview Questions and Answers


(Continued from previous question...)

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.

(Continued on next question...)

Other Interview Questions