I am new to the vector class and was exploring ways of inserting elements in a vector as per the user request. I tried a loop to insert ten elements in a vector using push_back() method. But my vector is only storing 9 elements if I start the indexing from zero.
#include<iostream>
#include<vector>
using namespace std;
int main()
{
vector<int>v1;
for(int i=0; i<10; i++)
{
cin>>i;
v1.push_back(i);
}
}
I am using visual studio, and I am only able to insert 9 elements in my vector. What can be the issue?