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 8872839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:19:01+00:00 2026-06-14T18:19:01+00:00

At the current moment, I’m trying to get the basics of C++ down so

  • 0

At the current moment, I’m trying to get the basics of C++ down so learning to use the find() Algorithm is where I’m at. When I use find() within my code, I am having problems when what I’m looking has more than one word (ex: when I look for FIFA I get the results I’m looking for. But when I look for Ace Combat, I get an Invalid game output). If anyone can shed any light on what I’m doing wrong, I’d greatly appreciate it.

//Games List
//Make a list of games I like and allow for user select one of the games

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    vector<string>::const_iterator iter;

    vector<string> games;
    games.push_back("FIFA");
    games.push_back("Super Mario Bros.");
    games.push_back("Ace Combat");
    games.push_back("Sonic");
    games.push_back("Madden");

    cout << "These are my some of my favorite game titles.\n";
    for (iter = games.begin(); iter != games.end(); ++iter)
    cout << *iter << endl;

    cout << "\nSelect one of these games titles.\n";
    string game;
    cin >> game;    
    iter = find(games.begin(), games.end(), game);
    if (iter != games.end())
        cout << game << endl;
    else
        cout << "\nInvalid game.\n"; 
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-14T18:19:03+00:00Added an answer on June 14, 2026 at 6:19 pm

    the problem is at cin.

    like
    cin >> game;

    if you input “Ace Combat”, game == “Ace”.

    it would stop at first blank.

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

Sidebar

Related Questions

The following code summarizes the problem I have at the moment. My current execution
The current code is compiling O.K at the moment and if a duplicate is
I need to find files written by some script at the current moment in
at the moment i´m trying to play around with JNI. My Java-Code : public
At the moment I am trying to force current language onto the list of
I'm trying to use SQL, REST or the Jira Api to find out what
Hallo, How can I calculate a current time moment + exactly one week? The
How to create datetime object representing the very last moment of the current month
current code (not working): /^script\s*type=\text\/javascript/i.test(tagName)
One of our current milestones on our (open source) project at the moment is

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.