C Program to demonstrate malloc dynamic memory allocation
Program
#include<stdio.h>
#include<stdlib.h>
int main()
{
int *p;
printf("Pointer before memory allocation is:\t%p\n", p);
p = (int *)malloc(sizeof(int));
printf("Pointer after memory allocation is:\t%p\n", p);
}
Output
$ gcc malloc-dynamic-memory-allocation.c
$ ./a.out
Pointer before memory allocation is: (nil)
Pointer after memory allocation is: 0x55d838d6c670