gah..!! Forgot basics...some how this free is not working, i ran program on windows and followed memory usage using task manager, which didn't show any reduction in memory usage after free statement.
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
int i=0,j,k;
char **ptr;
ptr = (char **)malloc(sizeof(char *)*10);
for (i=0;i<10;i++)
ptr[i] = (char *)malloc(sizeof(char)*5);
for (i=0;i<10;i++) //this loop has no significance
for (j=0;j<5;j++)
ptr[i][j] = 'r';
for (i=0;i<10;i++) //this loop has no significance
{
for (j=0;j<5;j++)
printf("%c ",ptr[i][j]);
printf("\n");
}
for (i=0;i<10;i++)
free(ptr[i]);
//at this point also program takes memory same as before
free(ptr);
//at this point also program takes memory same as before
system("PAUSE");
return EXIT_SUCCESS;
}