Initializing vectors

I got a suggestion to use vectors (STL) to obtain multiple lines of input. However, I am using an infinite loop to keep obtaining the lines of input, and this is causing problems inn the sense that the vector needs to be empty everytime I go through the loop.

How can I initialize the vector before every cycle.
gvijay1Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gvijay1Author Commented:
To make my question more precise..I need to remove every element in the vector before going to the next iteration.

I know that push_back is one of the inbuilt functions but is there one to remove every element of the vector?
 
0
gvijay1Author Commented:
To make my question more precise..I need to remove every element in the vector before going to the next iteration.

I know that push_back is one of the inbuilt functions but is there one to remove every element of the vector?
 
0
DKostovCommented:
theVector.erase(theVector.begin(), theVector.end());

Good Luck,
Dimitar
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

gvijay1Author Commented:
Thanks Expert,
             It was short and precise!!! I really needed that.
0
DKostovCommented:
The pleasure was mine
0
nietodCommented:
However, a shorter one would be

theVector.clear();

(Although DKostov's answer will work fine).
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.