A
Andres Steinhilber
Hi there..I would know why I'm having a problem when I'm trying to
free a pointer..
this is the code:
#include<stdio.h>
#include<stdlib.h>
int *reserv_mem(void);
int main()
{
int var = 9;
int *ptr = reserv_mem();
printf("\n enter value : ");
ptr = &var;
free(ptr); //HERE IS THE ERROR
return 0;
}
int *reserv_mem(void)
{
int *temp = NULL;
temp = (int *) malloc(sizeof(int));
return temp;
}
free a pointer..
this is the code:
#include<stdio.h>
#include<stdlib.h>
int *reserv_mem(void);
int main()
{
int var = 9;
int *ptr = reserv_mem();
printf("\n enter value : ");
ptr = &var;
free(ptr); //HERE IS THE ERROR
return 0;
}
int *reserv_mem(void)
{
int *temp = NULL;
temp = (int *) malloc(sizeof(int));
return temp;
}