memory lead

Go4Expert Member
10Sep2007,21:42   #1
buddy's Avatar
what is mean by memory leak in c programming ?? can anyone explain with an example??plz.
Team Leader
10Sep2007,21:51   #2
DaWei's Avatar
If you allocate memory dynamically from the heap, then don't return it before the program exits, it's no longer available for other programs.
Go4Expert Member
11Sep2007,10:23   #3
listendinesh's Avatar
Here is the example

Code:
int main()
{
char *buffer1;
char *buffer2;
buffer1 = (char *)malloc(5*sizeof(char));
buffer2 = (char *)malloc(5*sizeof(char));
buffer1 = buffer2; // This will lead Memory leak
.
.
.
.
}