Multiple choice

(A) If malloc() successfully allocates memory then returns the number of bytes it has allocated. (B) malloc() returns a float pointer if memory is allocated for storing float. (C) malloc() returns a NULL if it fails to allocate request memory. Which of the above statements are true?

  1. A, B, C

  2. B, C

  3. C

  4. None of these

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The malloc function returns a void pointer (void*) to the start of the allocated memory block, or NULL if the allocation fails. It does not return the number of bytes allocated, nor does it automatically return a specific type like a float pointer.