Hello
When my function storefiles() returns to main ,the names of the files that it should have stored in my arguement vector are not there,or at most only one is there.
As you can see in storefile() there is a for loop that steps along the arguement vector to make sure all the files that should be there are there.
This works fine.
But if i do the same thing in main() once storefiles has returned, none;or maybe one or two of the filenames are there ??.
I was thinking about making "store" external but I thought pointers negated the need for this?
I added retrun store line ,equating it to the store variable in main() thinking that realloc was moving the storage to a different place,but this didn't help
thanks in advance.
Code:
char **storefiles(struct dirent *dS,char **store,int count,int len)
{
int c;
c=count+2;
if((store=(char**)realloc(store,sizeof(char *) * c))==NULL)
return -1;
if((*(store+count)=(char *)malloc(sizeof(char *) * len))==NULL)
return -1;
*(store+count)=strcpy(*(store+count),dS->d_name);
*(store+count+1)=NULL;
for(c=0;*(store+c) !=0;c++)
printf("%s found.\n",*(store+c));
return store;
}