About C Interview Questions-Dynamic Memory Allocation:
This C Interview Questions-Dynamic Memory Allocation page explains clearly about all the frequently asked questions in C Language technical interviews on Dynamic memory allocation including static memory, dynamic memory and predefined functions to allocate and deallocate memory.
C Interview Questions-Dynamic Memory Allocation
What is the static memory?
Static memory is nothing but fixed in size.
Primitive variables, Arrays, strings variables can have a fixed size.
What is the Dynamic memory?
Dynamic memory means, size varies depends on insertion and deletion of elements.
Dynamic memory allocation is the concept of allocating memory using pointers when required.
Can we allocate dynamic memory in C?
stdlib.h header file providing pre-defined functions to allocate and de-allocate memory in C
DMA functionality available in which header file?
stdlib.h header file.
What is the use of malloc() function?
malloc() function is used to allocate memory dynamically to structure variables.
How to allocate memory dynamically for array variables?
Using calloc() function, we can allocate memory dynamically to arrays through pointers in C
Why we use realloc() function?
Using calloc() function we can allocate fixed length memory to arrays. So if we want to modify the size
of array we used realloc() function.
How to de-allocate memory in C?
using free() function.
What size_t represents in C?
size_t represents unsigned(+ve int) value in C programming.
Why malloc() function returns void* ?
malloc() function can allocate memory to any type of structure type and returns base address of
memory block. Hence it returns common pointer type void*.
What value will be returned if malloc() function failed?
it returns a NULL pointer if failed in allocating memory.