1. Home
  2. Computer Science MCQs
  3. C Programming
  4. Which standard C header must be included to use malloc()…

Added 30 Nov -0001

Which standard C header must be included to use malloc(), calloc() and free()?

  1. <math.h>
  2. <stdlib.h> Correct answer
  3. <stdio.h>
  4. <string.h>

Correct answer

B. <stdlib.h>

13 views

MCQSEXAM

Explanation

malloc, calloc, realloc and free are declared in , the general-utilities header that also holds atoi, rand and exit. declares console and file I/O such as printf and fopen, while holds strcpy and memset. Mixing these up is a common compile-time trap: calling malloc without its declaration produces an implicit-declaration warning or error.

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