#include<stdio.h>
#include<stdlib.h>
main()
{
int *a;
a=(int*)malloc(sizeof(int));
*a=100;
printf("*a%d",*a);
free(a);
a=(int*)malloc(sizeof(int));
*a=200;
printf("a%p",a);
*a=200;
printf("a%d",*a);
}
a) Error
b) Memory leak
c) Dangling pointer arises
d) 200 is printed as output
What will happens if the statement free(a) is removed in the following C code?
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
What will happens if the statement free(a) is removed in the following C code?
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!