include “stdio.h”
include “string.h”
int getMem(char ***p,int num)
{
char **temp = NULL;
int i = 0;
if (p == NULL)
{
return -1;
}
temp = (char *)malloc(sizeof(char )*num);
for (i = 0; i < num; i++)
{
temp[i] = (char )malloc(sizeof(char) 100);
}
*p = temp;
return 1;
}
void freeMem(char ***p,int num)
{
char **temp;
int i = 0;
if (p == NULL)
return ;
temp = *p;
for (i = 0; i < num; i++)
{
free(temp[i]);
}
free(temp);
*temp = NULL;
}
void main()
{
char **p = NULL;
int num = 5;
getMem(p, num);
}