Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7755749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:38:32+00:00 2026-06-01T12:38:32+00:00

I am building a games library and I want the user to be able

  • 0

I am building a games library and I want the user to be able to delete games.
I am trying to use the .erase() function but i am making a mistake somewhere.
I am studying my code for days and i can’t find a anwser.
Why? Beceause I am just 15 and don’t have that programming mind every other programmer has. That’s why i don’t call myself a programmer but just an ambiteuse teenager. Please help me. (Sorry for my spelling)

Here’s my code:

int main()
{
    vector<string>::const_iterator myIterator;
    vector<string>::const_iterator iter;             
                                            vector<string> games;                                
    games.push_back("Crysis2");
    games.push_back("GodOfWar3");
    games.push_back("FIFA12");

    cout <<"Welcome to your Games Library.\n";
    cout <<"\nWarning!!! Don't type spaces, put ecerything together!!!\n";
    cout <<"\nThese are your games:\n";
    for (iter = games.begin(); iter != games.end(); ++iter)
    {
        cout <<*iter <<endl;
    }
    //the loop!
    string action;
    string newGame;

    cout <<"\n-Type 'exit' if you want to quit.\n-Type 'add' if you want to add a game.\n-Type 'delete' if you want to delete a game.\n-Type 'find' if you want to search a game.\n-Type 'game' if you don't know what game to play. ";

    while (action != "exit")
    {


        cout <<"\n\nWhat do you want to do: ";
        cin >> action;


        if (action == "add")
        {
            cout <<"\nType the name of the game you want to add: ";
            cin >> newGame;

            games.push_back(newGame);

            for (iter = games.begin(); iter != games.end(); ++iter)
            {
                cout <<*iter <<endl;
            }

            continue;
        }
        else if (action == "delete")
        {
            cout <<"Type the name of the game you want to delete: ";
            cin >> newGame;

            iter = find(games.begin(), games.end(), newGame);

            if(iter != games.end())
            {
                games.erase(newGame);
            }
            else
            {
                cout<<"\nGame not found.";
            }

            continue;
        }
        else if (action == "find")
        {
            cout <<"Which game you want to look for in your library: ";
            cin >> newGame;

            iter = find(games.begin(), games.end(), newGame);

            if (iter != games.end())
            {
                cout << "Game found.\n";
            }
            else
            {
                cout << "Game not found.\n";
            }

            continue;
        }
        else if (action == "game")
        {
            srand(static_cast<unsigned int>(time(0)));
            random_shuffle(games.begin(), games.end());
            cout << "\nWhy don't you play " <<games[0];

            continue;
        }
        else if (action == "quit")
        {
            cout <<"\nRemember to have fun while gaming!!\n";
            break;
        }
        else
        {
            cout <<"\nCommand not found";
        }
    }
    return 0;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T12:38:34+00:00Added an answer on June 1, 2026 at 12:38 pm

    erase() takes an iterator (in this case, the result of find, which is iter), not a string (like newGame).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Like with browser games. User constructs building, and a timer is set for a
I'm building a Monopoly game in Java and I want it to be able
I am building a library, called physgameengine, to aid in building games. This game
When building advanced JS-interfaces and games I've found that I have to dig deeper
I'm building a game with nodejs 0.6.18 expressjs 2.5.8 and mongoose 2.6.7. I'm trying
I have been building a game for a while (nearly done) - But the
I'm building a flex 4 container for action script 2 flash applications. I use
I am interested in programming for games. I am currently building an iphone game
I'm building a basic search function for my site. Realising that the most useful
I want to make isometric, tile-based, iPhone games with cocos2D. Sprites need to be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.