Which of the following is used for dynamic memory allocation in C ?
Tripura Public Service Commission - 2026,
Answer: D
Dynamic memory allocation in C uses malloc.
malloc(size), declared in <stdlib.h>, reserves the requested number of bytes on the heap at run time and returns a pointer to them (or NULL if it fails). Its companions are calloc (allocates and zeroes), realloc (resizes) and free (releases).
new and delete are C++ operators and do not exist in C, which makes them the trap. There is no standard C function called create.
Please log in or register to report this question.