I am trying to develop a C++ program. I am facing a problem. I have declared an array of length 100 as int arr[100].
But I have only filled 20 entries in it. Now I want to find the total number of elements in the array, which should be 20. How do I find the number of elements filled in the array?
I have tried
int size= sizeOf(arr)/sizeof(int); but this gives me 100. I only want to get the elements which I have allowed the user to enter.
Actually, there is a situation where the number of generated outputs can be any number. So I assigned each value in a separate array as arr[]. Then I want a loop through the length of the array.
How to calculate the total number of outputs I am getting in the array?
std::vector?