I was wondering if anyone can give me an answer to this:
Here is the code
int main(int argv, char *argc[])
{
char **name;
char *tempstring = "this string"
name = (char**)malloc(sizeof(char**) * NoOfInFiles))
for(i=0;i<NoOfFile;i++)
name[i] = strdup(tempstring);
// Do other stuff
free(name);
return(0);
}
ok now my question is this:
If the memory for name is freed, will it free the memory that has been allocted by strdup() or will that memory still be set aside?
The way I think it works is that I would have to do this first :
for(i=0;i<NoOfFiles;i++)
free(name[i]);
before freeing name? is this right or am I just messed up?
And the pointer to pointer has to stay. It is too deep in the original code to remove it.
any help would be appreciated