C Programming Tutorial DAY 12 |Dynamic Memory Allocation |malloc | calloc|realloc|free|CodeDeveloper

Dynamic Memory Allocation in C using malloc(), calloc(), free() and realloc()
Since C is a structured language, it has some fixed rules for programming. One of it includes changing the size of an array. An array is collection of items
stored at continuous memory locations.

C provides some functions to achieve these tasks. There are 4 library functions provided by C defined under stdlib.h header file to facilitate dynamic memory allocation in C programming. They are:
1.#malloc()
2.#calloc()
3.#free()
3.#realloc()

1. “malloc” or “memory allocation” method in C is used to dynamically allocate a single large block of memory with the specified size.

2. “calloc” or “contiguous allocation” method in C is used to dynamically allocate the specified number of blocks of memory of the specified type. It initializes each block with a default value ‘0’.

3.“realloc” or “re-allocation” method in C is used to dynamically change the memory allocation of a previously allocated memory.

4“free” method in C is used to dynamically de-allocate the memory.
blogger link : http://ceesty.com/w5ifQQ
———————————————————–
facebook link :http://bit.ly/2Bgm1Eg
———————————————————–
#codedeveloper
#codebehind
#CProgrammingTutorial

Post Author: hatefull