How do we take input from user in C++ and store in vector when the number of elements is variable?
I know that when we know the number of elements we can use pretty much this code:
for(int i=0;i<n;i++)
{
cin >> element;
my_vector.push_back(element);
}
But in my case I don't know what the size is going to be, so how can I do this?