#include <iostream>
#include <vector>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
vector<int> v{1, 23, 4, 4, 5, 566, 67, 7, 87, 8, 8};
size_t s = v.size();
for (size_t i = 0; i < s; i++)
{
cout << v.at(i) << " ";
v.pop_back();
}
return 0;
}
In the above code, I am straightaway getting out of bounds error without any output.
I expected that it would go out of bounds once it has printed half the vector, but apparently, that's not the case.
PS: There are no compile-time errors/warnings.
Appreciate any help!