Thread: Force end

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    7

    Force end

    Is there any way to force a program to shut down without using code to make it crash (or using a while loop)? If the answer is in a tutorial on this site, please tell me which tutorial and I'll find it myself. The reason I want this is to shut down the program when it fails to load a file, preventing the program from screwing up by calling data from a file that doesnt exist, or is corrupted, damaged etc. If there isn't any way to do this please tell me. I'll use the while loop if I have to, but I thought there might be a quicker and easier way to do it.
    EDIT: I have another problem. I just wrote this switch-case bit and Dev C++ is telling my that there are undeclared functions (n, l, and y)

    Code:
     
    cout<<"Would you like to create a new data file or load an existing one.\n";
    cout<<"[N]ew or [L]oad (Capitalized)\n";
    cin>> newload;
    cin.ignore();
    switch ( newload ) {
    case n:
      cout<<"Are you sure? Saved data will be Erased.\n";
      cout<<"[Y]es or [N]o (Capitalized)\n";
      cin>> sure;
      cin.ignore();
        switch ( sure ) {
        case y:
          break;
        case n:
    //This is where i want to put the "End program" statement if I can
          break;
        default:
          break;
        }
      break;
    case l:
      break;
    default:
      break;
    }
    I havent actually put in the code between the case and break sections yet, but as far as I can tell, I don't have any errors in it. I'm also getting a "Warning: Unreachable code at beginning of switch statement" error that I don't understand. I know it's a lot of questions, but I can't find my error, so I need help. Yes, I did check the Switch-Case tutorial but as far as I can tell, I haven't made an error.
    Last edited by Redattack34; 09-06-2005 at 06:00 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Modify to make Doubly Linked List
    By Dampecram in forum C Programming
    Replies: 10
    Last Post: 11-03-2008, 07:25 PM
  2. Adventures in labyrinth generation.
    By guesst in forum Game Programming
    Replies: 8
    Last Post: 10-12-2008, 01:30 PM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. socket newbie, losing a few chars from server to client
    By registering in forum Linux Programming
    Replies: 2
    Last Post: 06-07-2003, 11:48 AM
  5. Next Question...
    By Azmeos in forum C++ Programming
    Replies: 3
    Last Post: 06-06-2003, 02:40 PM