Thread: Quick Question

  1. #1
    Registered User
    Join Date
    Mar 2010
    Location
    Salem's Lot
    Posts
    19

    Quick Question

    If someone chooses the wrong path I want the program to end there but if they choose the right path I want it to keep going.

    Here's the code so far.
    Code:
    int choice2;
    switch (choice2)
    {
        case 1:
        cout << "You walk towards the room.  The hallway you are in feels like it is closing in around you and you get an eery feeling as you push open the door.\n\n";
        break;
        case 2:
        cout << "You sit down on the couch and the television turns on to your amazment!  You try to see what is on the screen but your vision begins to fade.  What is this strange feeling you wonder as everything around you begins to blackout.";
    }
    Thanks in advance.

    -SP

  2. #2
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    Look up the exit() function in <stdlib.h> (in C) or in <cstdlib> (in C++, where the function is in the std namespace).

    In future, remember that questions are normally expressed in a way that involves a '?'.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  3. #3
    Registered User
    Join Date
    Mar 2010
    Location
    Salem's Lot
    Posts
    19
    normally expressed in a way that involves a '?'.
    Yes, normally. In this case it didn't have to be.

    Thanks.

    -SP

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Yes, it did.
    If someone chooses the wrong path I want the program to end there but if they choose the right path I want it to keep going.
    That is a statement; ie, what you want it to do. But you never asked a question to get an answer for.
    We simply guessed what you wanted to hear and provided it.

    In the future, try using the ?. It really does help.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Very quick math question
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 10-26-2005, 11:05 PM
  2. very quick question.
    By Unregistered in forum C++ Programming
    Replies: 7
    Last Post: 07-24-2002, 03:48 AM
  3. quick question
    By Unregistered in forum C++ Programming
    Replies: 5
    Last Post: 07-22-2002, 04:44 AM
  4. Quick Question Regarding Pointers
    By charash in forum C++ Programming
    Replies: 4
    Last Post: 05-04-2002, 11:04 AM
  5. Quick question: exit();
    By Cheeze-It in forum C Programming
    Replies: 6
    Last Post: 08-15-2001, 05:46 PM