What functions are used for dynamic memory allocation in C language?
- The malloc() function is used to allocate the memory during the execution of the program.
- It does not initialize the memory but carries the garbage value.
- It returns a null pointer if it could not be able to allocate the requested space.
- The calloc() is same as malloc() function, but the difference only is that it initializes the memory with zero value.
- The realloc() function is used to reallocate the memory to the new size.
- If sufficient space is not available in the memory, then the new block is allocated to accommodate the existing data.
In the above syntax, ptr is allocated to a new size.
The above syntax releases the memory from a pointer variable ptr.