On Feb 19, 6:00 pm, "Zach" <net...@gmail.com> wrote:
> Could someone please illustrate this with some ANSI C code? 
>
> Zach
If you just declare a variable or array like this:
int n;
char ac[5];
then it's on the stack. When it goes out of scope (i.e. when you exit
the function or block in which it was declared) the memory which it
took up is automatically given back.
If you allocate memory using malloc, like this:
char * pc = malloc(5);
then the memory is allocated on the heap, and will not automatically
be given back when the variable goes out of scope, so you have to
explicitly free the memory:
free(pc);
Rachael