Quote:
Originally Posted by aisha.ansari84suppose there is a function which allocates memory for a temporary variable temp , does some work and then returns temp.
i think there should be a memory leak in this case as i cannot free temp ,right so how can i control memory leak here
Code:
#include<malloc.h>
int* fun();
int main()
{
int *p2 = fun();
free(p2);
return 0;
}
int* fun()
{
int *p1 = (int *)malloc(10);
return p1;
}
