Hi at everyone, I have a quite stupid question.
I should fill two vectors of unknow lenght, my attempt is:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
int main()
{
vector<double> price;
cout << "Fill the vector price, when you want insert informations inside another vector enter stop" << endl;
for(double objectprice; cin>>objectprice;)
price.push_back(objectprice);
cout << "Fill the vector weight, when you want end it, enter stop" << endl;
vector<double> weight;
for( double objectweight; cin>>objectweight;)
weight.push_back(objectweight);
return 0;
}
But when I enter a string or a char the program shutdown instead of let me enter the elements in the second vector.
What should I change??
Thak to everyone.
Hi! Thank you for the fast reply. I saw your videos but it doesn't help me.
I mean, the video shows the implementation of a for loop. Now this doesn't help me because i can't set the lenght of the vector in advance. What I'm searching is code that push back elemnts inside a vector and stops only when i enter a string or a char -or a particular key-.
My code works only for the first vector...
Do you have any advice?
Thank you anyway again.