Thread: int main()

  1. #1
    Registered User
    Join Date
    Oct 2001

    Question int main()

    ok, this is just a portion of my actual program, I am having trouble down near the bottom, if you have any suggestions please feel free, I am always open to suggestions.

    cout << "press 1 to enter or 2 not to enter"<<endl<<endl<<endl;
    cin >> x;
    if (x==1)
    cout << "Would you like a bed for the night or tend to the bar?"<<endl
    << "press 1 for a room or 3 to tend to the bar."<<endl<<endl;
    cin >> x;
    if (x==1)
    int main(1);
    cout << "very well sir, your baggage will be taken to your room and your horses will be"<<endl
    <<"put in the stall around the corner. Dinner is at 7:00pm sharp, dont be late."<<endl
    <<"Thank you sir and enjoy your stay at the Green Dragon 1 if you "<<endl
    <<"would like to go to your room or 4 if you would like to attend the game room."
    cin >> x;
    if (x==1)
    { cout << "Right sir, your room is down that hall there and to the left, first door"<<endl
    << "on the right marked 09. Enjoy your rest sir, if you need anything dont be afraid"
    << "to come out and ask one of our boys for help."<<endl<<endl;
    return 0;
    if (x==4)
    cout << "Welcome to the game room sir, I am Master Meriadoc. I will be your host"<<endl
    << "for tonight. Ok, to get things started press 1 if you would like to play the "<<endl
    << "game or press 5 if you would like to leave."<<endl<<endl;
    cin >> x;
    if (x==5)
    *"this is where I want to loop it back to where it says int main(1), any suggestions?"


  2. #2
    I can think of three ways that this could be attempted.

    First, and most likely, use a loop; probalby with a flag, depending on what comes later. For example how does player cancel the game? Does player need to go back to the top or can he decide he doesn't want to play any of the games and can they go to the room directly, without going to back to the top?

    An alternative, would be to try the keyword continue.

    Last, and definitely last, the goto() command could be considered, but ONLY as a last resort.

  3. #3
    Casual Visitor
    Join Date
    Oct 2001
    Try something like this for your prompts, and put the entire thing in a do while loop or forever loop with a break statement to exit if you want it to cycle through more than once.

    #include <iostream.h>

    int main()
    int number;

    cout << "enter 1 blah enter 2 blah ";
    cin >> number;

    case 1: cout << "stuff for option one";
    case 2: cout << "stuff for option two";
    default: cout << "That wasn't a valid option.";

    return 0;
    I haven't used a compiler in ages, so please be gentle as I try to reacclimate myself. :P

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Drawing Program
    By Max_Payne in forum C++ Programming
    Replies: 21
    Last Post: 12-21-2007, 05:34 PM
  2. Debug Error Really Quick Question
    By GCNDoug in forum C Programming
    Replies: 1
    Last Post: 04-23-2007, 12:05 PM
  3. Switch/case Problems (long code in post)
    By Wraithan in forum C++ Programming
    Replies: 2
    Last Post: 12-01-2005, 06:40 PM
  4. getting a headache
    By sreetvert83 in forum C++ Programming
    Replies: 41
    Last Post: 09-30-2005, 05:20 AM
  5. Quack! It doesn't work! >.<
    By *Michelle* in forum C++ Programming
    Replies: 8
    Last Post: 03-02-2003, 12:26 AM