hello i am trying to write a program that allows user to make a list using vectors and iterators
i am able to add a title, list items, remove all, but were my trouble is when i want to remove just one from the list i am not sure how if someone could help me please
this is what i got problem is in the if ( input == remove)
#include <iostream>
#include <vector>
#include <string>
using namespace std;
bool done = false;
int main()
{
vector <string> vectorGameList;
cout << "\t\t\tWelcome!\n\n";
cout << "Enter 'quit' to end list & close.\n";
cout << "Enter 'list' to lists games on list so far.\n";
cout << "Enter 'add' to add games to list.\n";
cout << "Enter 'remove' to remove a game from the list.\n";
cout << "Enter 'clear' to remove all games on list.\n";
do
{
vectorGameList;
vector< string >::iterator myIterator;
vector< string >::const_iterator iter;
cout << "Enter your selection: ";
string input;
cin >> input;
if ( input == "add" )
{
string gametoAdd;
cout << "\nwhat game would you like to add: ";
cin >> gametoAdd;
vectorGameList.push_back(gametoAdd);
done = false;
}
if (input == "list")
{
cout << "\nYou have " << vectorGameList.size() << " game(s) on list so far" << endl;
cout << " Your Game List includes:" << endl;
int gameNum= 1;
for (iter = vectorGameList.begin(); iter != vectorGameList.end(); ++iter)
{
cout << gameNum++ << ") " << *iter << endl;
}
done = false;
}
if ( input == "quit" )
{
done = true;
}
if ( input == "remove" )// here my problem begins, if user inputs remove i then want them to input what item they want off the list
{
cout << " which do you want to remove ";
// cannot remove certain string from vector
vectorGameList.erase((vectorGameList.begin());
done = false;
}
if ( input == "clear" )
{
vectorGameList.clear();
cout << "\nYOUR LIST IS NOW EMPTY!!!" << endl;
done = false;
}
}while(!done);
cin.get();
return 0;
}
thanks alot