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