Suppose I have an array, defined as
int arr[10]; I want to progressively fill this array (assuming to not run out of the memory allocated for the array), according to a loop of the form
for(int i = 0; i < some_number; i++) if(some_condition) add_element_to_arr What is the best way to do this? Two methods I can think of are 1) using an auxiliary variable to remember the number of stored values, or 2) using a pointer to do the same thing.
What is the preferred/standard/conventional way to do this?
Also, having to do this kind of operations for multiple arrays, to remember how many values have been added to each array one has to use an auxiliary variable for each array. What is the preferred way to deal with this?