1. Home
  2. Computer Science MCQs
  3. C Programming
  4. For a non-NULL result, what does the C standard guarantee…

Added 30 Nov -0001

For a non-NULL result, what does the C standard guarantee about the pointer returned by malloc?

  1. It stays valid until the enclosing block ends
  2. It is aligned for any type with a fundamental alignment Correct answer
  3. It points into the current function's stack frame
  4. It is zero-filled before it is handed back

Correct answer

B. It is aligned for any type with a fundamental alignment

15 views

MCQSEXAM

Explanation

The block returned by malloc is aligned so that it can hold any object type with a fundamental alignment requirement, which is why the result may be assigned to any pointer type without a misalignment fault.

Reference

Asked in: NTS, PPSC IT, Campus Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is B? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More C Programming MCQs

Practise all C Programming MCQs

Similar MCQs