So for my school project, a large CSV file will be entered through stdin
and we will have to sort it based on column and print it out as a sorted csv file.
The step I am on right now is figuring out how to keep realloc
ing a struct
of arrays so that it will grow if there is not big enough to hold the data coming in from stdin
. We don't know the exact amount of rows that will be inputted in the CSV file. Right now we just used a static amount to test and see if the values are assigned to the struct
s.
I am still a beginner at C so I do not clearly know how I would iterate through a pointer like I would iterate through an array. Since we are using a static amount of struct
s in the array, we can just iterate using array[i]
like in Java but how would you iterate through something like *array
?
I do not know where to start for creating this dynamic array. I tried
struct array* testArray = (array*)malloc(sizeof(testArray));
but I have no idea how to iterate through it like I did with the static array by using array[i]
.
Any help would be greatly appreciated, sorry for the wall of text...