Game library problem

I need to get the program to let a user add a game remove a game and show the games and I am really lost and could use some help.

I display the list of games already then I ask the player to add a game and I cannot figure out how to get what the player inputs to be the next game and so on to remove a game.

Here is the code I have so far:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int addgame;
    int removegame;
    int showgames;
    const int MAX_GAMES = 20;
    
    cout << "\n\t\t\tWelcome to your personal game library.\n\n";
    
    vector<string> commands; //commands addgames, removegames, and showgames
    commands.push_back("addgames");
    commands.push_back("removegames");
    commands.push_back("showgames");
    
    vector<string>::iterator yourCommands;
    vector<string>::iterator yourGames;
    vector<string>::const_iterator iter;
    
    cout << "Your commands: \n";
    for (iter = commands.begin(); iter != commands.end(); ++iter)
        cout << *iter << endl;
        
    vector<string> games;
    games.push_back("street fighter 4");
    games.push_back("super street fighter 4");
    games.push_back("gunz");
    games.push_back("guild wars");

    
    cout << "\nYour Games: \n";
    for (iter = games.begin(); iter != games.end(); ++iter)
        cout << *iter << endl;
    
    cout << "\nType which game you would like to add: ";
    cin >> addgame;
    games.insert(games.end(), "lame");
    cout << "\nYour Games: \n";
    for(iter = games.begin(); iter != games.end(); ++iter)
        cout << *iter << endl;
        
    cout << "\nType which game you would like to remove: \n";
    cin >> removegame;
    games.erase(games.begin() +5);
    cout << "\nYour Games: \n";
    for(iter = games.begin(); iter != games.end(); ++iter)
        cout << *iter << endl;
        
    return 0;
    
}


Thank you for your time.
i would just have one vector, being a games vector. then have the list of games that you start with as you do. Then you can get the user input, and push_back that. Also when you do the user input you might want to do getline(cin, userInput) I think that is the proper method of doing that, just look up getline and it will tell you the paramaters, it allows you to get the entire line, so if the user inputs a sentence or multiple words, such as street fighter 4 then it takes in the entire sentence instead of the first word as cin does. I tried to do bow and arrow for a game that I had, and later when i tried to call that variable, the program freaked out on me because i didn't use the getline for it, so i'm guessing it's a good habit to get into using that.
I'm mainly confused on how to get the user input with games.insert(games.end(), "User input here");
Topic archived. No new replies allowed.