C++ Vector push_back()…pop_back()

#include<vector>
#include<iostream>
using namespace std;
int main()
{

    vector<string> list;
    cout<<"Please enter the names, press Q to quit:"<<endl;
    string name; //string //
    while(name!="Q")
    {
        cin>>name;
        list.push_back(name); //pushing string to the list
    }
    list.pop_back(); //poping string from the list
    list.pop_back();

    cout<<"You have entered "<<list.size()<<" names:"<<endl;
    for(int i=0; i<list.size(); i++)
    {
        cout<<list[i]<<endl;
    }


    return 0;
}

It would be a great help, if you support by sharing :)
Author: zakilive

Leave a Reply

Your email address will not be published.