returning data to main() via a pointer to a pointer.
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.
I think you've confused your use of store. I'd have declared it as char *store and used it as *store[n] to load the array (think of it as argv). It's late and my brain's not fully functional, but hopefully this'll give you a clue to get you moving again.;)
I thought the syntax **buffer and *buffer were the same...!???
I will give it a bash.
I split up the re-sizing of the buffer **store from the copying of the file name from dS->d_name to *store.
I think its cleaner.
I think the problem was because I was'nt explicitly equating the memory blocks in main() to the reallocated memmory blocks in my function??!?!!
I have done this with an explicit return and cast.
It has definitely given me food for thought anyway...
I also used the syntax suggested by eddiebaby1023 in the calling function in main() which does clean things up I think.
Although I didn't change the declaration. ;0).
Anyway it works now.
|All times are GMT -5. The time now is 09:49 AM.|