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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:27:56+00:00 2026-05-23T06:27:56+00:00

Please see the code fragment below, specifically the first ‘else if’ statement. I want

  • 0

Please see the code fragment below, specifically the first ‘else if’ statement. I want the user to have the ability to do this:

load filename

so I want to check that “load ” is in the string and attempt to open whatever is after “load “. However, string::npos seems to always be returned (string::npos just means there is no position).

I’m probably doing something stupid – this is basic stuff!

void Main::user_choice() {
    string choice;
    while(choice != "exit") {
        cout << "> ";
        cin >> choice;
        if(choice == "view") {
            Main::view_frameworks();
        }
        else if(choice.find("load ") != string::npos) {

        }
        else if(choice == "exit") {
            return;
        }
        else {
            cout << "Invalid command" << endl;
        }
    }
}
  • 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-05-23T06:27:57+00:00Added an answer on May 23, 2026 at 6:27 am

    cin >> choice stops reading before the first whitespace. You want getline(std::cin, choice) here.

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

Sidebar

Related Questions

I have problem with session and query execution,please see code below. class A implements
I have problem with session and query execution, please see code below. class A
Please see the code below. Basically, when the user creates an object of this
Please see code below: s = new Socket(nextHopIP, 3434); fileIn = new FileInputStream(fileName); fileOut
Please see the code below: #include <windows.h> int main(int argc, char* argv[]) { HANDLE
Please see the code here: http://pastie.org/1092106 When I call the method createPost on Blog,
Have been pulling out my hair trying to find out why my sessions are
I'm experimenting on this code that I got from the net (I'm trying to
How do I get DIV(.level2) to start executing the fadeOut() only if DIV(.level3) is
I am trying to develop a C++ application. Part of the Application is meant

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.