Ace Your C++ Skills 2026 – Rock the ‘Thinking in C++’ Challenge!

Question: 1 / 565

What does the malloc() function return if it fails to allocate memory?

NULL

0x0

An error code

Both A and B are correct

If the malloc() function fails to allocate memory, it will return a NULL pointer or a memory address of 0x0, depending on the system. Therefore, both options A and B are correct. Option C is incorrect because the malloc() function does not return an error code when it fails. Instead, it returns NULL or 0x0, indicating a failure to allocate memory.

Get further explanation with Examzify DeepDiveBeta
Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy