[Dev-C++] Freeing of allocated memory
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Jan M. <jan...@vo...> - 2007-06-01 13:07:43
|
Hello,
I would like to ask and clear the problem of freeing a memory previously
allocated.
I have got a program and this a simple example of something similar:
#include<stdlib.h>
#include<stdio.h>
void chng (int **in_a)
{
int *temp;
temp = malloc(sizeof(int));
*temp = 1;
*in_a = temp;
}
int main()
{
int *a;
chng(&a);
printf ("a = %d\n", a);
free (a);
return 0;
}
And I would like to know if this free (a);
at the end of main() frees also a temp pointer which is used in chng()
function.
It should to do this because it adress the same part of memory if I
understand it correctly.
If you notice any other problem with the thing above, plese tell me.
Thank you very much
Jan Mura
jan...@vo...
|