Hello all... I have a test upcoming on Malloc and was wondering if you could answer some questions for me.
do I need to call malloc for each instance that I want to store a string into a 2 dimensional array or can i just use realloc?
like for instance if i have a loop collecting strings into a 2 dimensional array and i call malloc to a certain "buffer" size outside of the loop, will i only need to call it once? i understand that i can use realloc to resize the buffer to the size of the largest line in the array. but would i need to use a temp array to store the current string then find its strlen and if that string is the largest line use realloc to resize the buffer?
was wondering if anyone could write some dummy code demonstrating the above... if not maybe just an explanation would be fine. Thanks all... =)
oh if you know any webpages that have good detailed examples of malloc that would be great because my book really sucks.