I have a list of records, at the starting I dont know the number of records. I need to read them into array. so is it advisable to read all record one by one & doing reallo
A realloc
isn't really very expensive. But calling realloc
for each element is a bit much. I suggest you do this:
Correctly guessing an adequate initial size also helps. So if 60% of your inputs are less than 100 records, start with that.