Hello. I'm just a beginner. Here is my problem. I have a data file with an unknown number of integers. I initialized an array of 100. I then input the file into the array. I know for a fact the elements of the file are less than 100. Now, I need to sort the array using bubble_sort but how can I avoid the zero values within the array? I will need to find the median of the sorted array. The only thing I need guidance on is how to modify the array with 100 to whatever the number of actual elements is? Is it possible? Thank you!
Do you know how to use std::vector? Unlike arrays, vectors can be resized. If you're trying to learn programming this would be a good time to learn about vectors. If you're just trying to get the assignment done, why not keep track of the number of integers being read from the data file? So, if you know that you only took x number of integers in from the data file, you can perform your sort only on the first x members of your array.
thank you hyperfine...that's exactly what I did and it worked out fine. Thank you shadowCODE. I had to use an array in this assignment but I appreciate the info about vectors. Thanks again!