C Programming - Memory Allocation - Discussion
Discussion Forum : Memory Allocation - Find Output of Program (Q.No. 1)
1.
What will be the output of the program?
#include<stdio.h>
#include<stdlib.h>
int main()
{
int *p;
p = (int *)malloc(20); /* Assume p has address of 1314 */
free(p);
printf("%u", p);
return 0;
}
Discussion:
57 comments Page 6 of 6.
Bhargavi said:
1 decade ago
Give me clear explanation.
Omkar kuchekar said:
1 decade ago
Anyone expert knows answer?
Anshul said:
1 decade ago
This is not recommendable as it leads to dangling pointer.
Shashank said:
2 decades ago
Saradhi is right. I checked in turboc.
Saradhi said:
2 decades ago
free(); it delets that arry where it points. array is deleted but not pointer. so, print the address of p 1314
Prajesh Bhushan said:
2 decades ago
Please help me understand the logic behind !
Dilpreet said:
2 decades ago
Please give the explanation.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers