Just declare the array to be the maximum expected size and use a separate int variable to indicate how many array elements are actually in use.
Just declare the array to be the maximum expected size and use a separate int variable to indicate how many array elements are actually in use.