Hi Guys;
Thanks a mill, totally misunderstood how realloc worked and it was killing me!
I thought it added on to the current load!
Here is my code now:
Code:
int main()
{
int i;
char **pdata;
//pdata = malloc(1 * sizeof(*pdata));
pdata=calloc(4, sizeof(*pdata));
for(i=0;i<4;i++)
{
printf("Enter a name");
pdata[i] = malloc(STR_SIZE);
scanf("%s", pdata[i]);
}
pdata=realloc(pdata, 5*sizeof(*pdata));
pdata[4]=malloc(STR_SIZE);
printf("Enter a string");
scanf("%s", pdata[4]);
for(i=0;i<5;i++)
{
printf("\n%s", pdata[i]);
free(pdata[i]);
}
}
Thanks again.