I have been at this problem for the last 6 hours and have been hitting google like mad to no avail.
Right I need a pointer to an array. This array contains pointers to Linked lists. Im going to have to malloc it since I dont know the array size until runtime.
LList **array
This was my first thought but this just gives me a pointer to an array of LList. Or atleast that is my understanding. Can someone give me a hand?
EDIT: Some info on how it would be used: I am implementing a very basic hash table. There is a structure that contains a pointer to an array of pointers to linked lists.
It needs to be a pointer to the array so that when I resize the table. I can just change the pointer to point to the larger table.
It sounds like you’re on the right track.
arrayis now an array of pointers toLList, and elements such asarray[3]will be a pointer to aLList.Arrays and pointers are very similar in C (but not identical!), as shown by the classic example:
*(array + 2)is mostly equivalent toarray[2].Edit:
When you need to resize the table, you’ll just need to
reallocthe additional space:new_arrayandold_arraymay or may not be the same pointer afterwards, but either waynew_arrayis guaranteed to be a pointer to enough space to hold the new array (orNULLif the memory couldn’t be allocated)2nd Edit:
As user411313 alluded, if you want the actual pointer to the array, you’ll need to take the address of the array: