Right now I'm working on adding the game titles, which I have figured out, however I want to loop it with a menu so that if the user hits 1, they can add another game, 2 they can remove a game, so on. So I figure to do this I need a loop, so I try a do loop. However it's not allowing me to add ther part where I make the menu and get the input from the user, I'm assuming because I do not initialize the variable that holds the user's input, and if I initialize it, for example I tried to set it to 0 before getting input, it still didn't work. Perhaps I'm just trying to use the wrong loop? I don't quite understand for loops unless I want the program to count for me.
Sorry for the block of text, just wanted to make clear what I'm having a problem with. Also I've only been into the book for about a week so a lot hasn't sunk in yet so the mistake may be obvious... Here's my code:
//Program that allows a user to maintain a list of his or her favorite games.
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
vector<string> gameList;
vector<string>::iterator myIterator;
vector<string>::const_iterator iter;
do
{
unsigned short int options;
cout << "Select an option:\n";
cout << "1 - Add a game to your favorites list.\n";
cin >> options;
string game;
cout << "\nAdd a game to your favorites: ";
cin >> game;
gameList.insert(gameList.end(), game);
cout << "\nYour current list:\n";
for (iter = gameList.begin(); iter != gameList.end(); ++iter)
cout << *iter << endl;
} while (options == 1);
char theEnd;
cin >> theEnd;
return 0;
}PS The variable theEnd is just there so the program doesn't automatically close. Using Dev-C++ and don't want to use .bat file every time I check a program, figured it'd be a simple way.







