C Dynamic Memory Allocation
C Dynamic Memory Allocation
❖ malloc(),
❖ calloc()
❖ free()
❖ realloc().
malloc()
The name "malloc" stands for memory allocation.
Syntax of malloc()
Example
C calloc()
The name "calloc" stands for contiguous allocation.
Syntax of calloc()
Example:
C free()
Dynamically allocated memory created with
either calloc() or malloc() doesn't get freed on their own. You must
Syntax of free()
Syntax of realloc()
int main(){
scanf("%d", &n1);
printf("%u\n",ptr + i);
scanf("%d", &n2);
// rellocating the memory
free(ptr);
return 0;
Enter size: 2
26855476
26855476
26855480
26855484