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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:59:50+00:00 2026-06-15T02:59:50+00:00

Hey Basically i have 2 functions: void Inventory:: showInventory() { char input[80]; cin >>

  • 0

Hey Basically i have 2 functions:

void Inventory:: showInventory()
{
    char input[80];
    cin >> input;
    char inventoryRequest[] = "i";
    //compare the player input to inventoryRequest (i) to see if they want to
    //look at inventory.
    int invent = strcmp (input,inventoryRequest);

    if(invent == 0) {
        //vector<string> inventory;
        cout << "You have " << inventory.size() << " items.\n";
        cout << "\n******Inventory******";
        cout << "\nYour items:\n";

        for (int i= 0; i< inventory.size(); ++i) {
            cout<< inventory[i] << endl;
        }
    }

}

void Inventory :: displayInventory(const string str) {
    char input = 0;
    do
    {
        cout << str << endl;
        cin >> input;
    }
    while((input != 'i') && (input != 'I') && (input != 'n') && (input != 'N'));
    showInventory();
    //return input;
}

showInventory compares the player input to i.
display inventory only lets the user press i or n.
i to view the inventory and n to skip.
But when i is pressed. It causes a double line.

Meaning i has to be pressed twice to view the inventory.

I have tried numerous things to stop this from occuring. But i have not succeeded and most of the time the inventory cannot be viewed at all.

Can anybody help me with this.
Thanks in advance.

  • 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-15T02:59:52+00:00Added an answer on June 15, 2026 at 2:59 am

    Try using a parameter for input on void Inventory::showInventory(), and eliminating the second cin, something like this:

    void Inventory:: showInventory(char input)
    {
        //char input[80];
        //cin >> input;
        //char inventoryRequest[] = "i";
        //int invent = strcmp (input,inventoryRequest);
        //compare the player input to inventoryRequest (i) to see if they want to look at inventory.
        //if(invent == 0)  // REPLACE THIS WITH THE LINE BELOW
        if(input == 'i')
    

    And then when you call it, do it like this:

        showInventory(input);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey all. Basically I have a page full of text input fields with default
Hey all, basically i have an empty AS3 fla file with just the following
Hey, so basically I have this issue, where I'm trying to put an equation
Hey all, basically, i have an array: array('a', 'b', 'c'); Now i run it
Hey all, so basically I have a very simple layout with a header image,
Hey guys. Basically I have a CSS triangle that I've created, and it sits
Hey everyone, not sure what is going on here :( Basically I have a
WordPress has a group of functions call pluggable functions; basically, they are designed to
Hey guys was hoping you could help me out. basically i'm working on a
Hey guys I'm not sure how to write this in AS3, but basically I

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.