exiting instantly

This is a discussion on exiting instantly within the C++ Programming forums, part of the General Programming Boards category; if a function returns type data bool and we want to exit the program without returning to main(). what's the ...

  1. #1
    kohatian3279
    Guest

    Question exiting instantly

    if a function returns type data bool and we want to exit the program without returning to main(). what's the syntax?

  2. #2
    Registered User Cela's Avatar
    Join Date
    Jan 2003
    Posts
    362
    #include <cstdlib>

    exit(EXIT_STATUS);
    *Cela*

  3. #3
    kohatian3279
    Guest

    ??

    whats that EXIT_STATUS?

  4. #4
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    An integer exit status. 0 normally indicates success, anything else is some kind of informational error code. If you are not interested in the value, say exit(1). Be careful.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  5. #5
    Registered User Cela's Avatar
    Join Date
    Jan 2003
    Posts
    362
    >>whats that EXIT_STATUS?
    A value that I have no way of guessing since you didn't mention what operating system/compiler you use. It's meant to be read as "Insert your favorite exit status here". :-)
    *Cela*

  6. #6
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Just wanted to say that exiting somewhere IN the program is
    a bad thing. If you ever want to go more advanced programming
    (win32,OpenGL) you'lle notice that you can't just exit somewhere,
    But need to send a signal back to main so it exits from main.

    Anyway for console apps it doesn't cause any trouble to exit
    anywhere just wanted you to know.

    Code:
     exit(1);

  7. #7
    Banned frenchfry164's Avatar
    Join Date
    Oct 2001
    Posts
    1,552
    even doing this in a basic windows app will mess things up. Memory leaks are only the tip of the iceberg of side effects.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Pausing before exiting function?
    By Matus in forum C Programming
    Replies: 3
    Last Post: 10-21-2008, 03:00 PM
  2. Exiting the program.
    By Taka in forum C Programming
    Replies: 6
    Last Post: 10-14-2007, 09:24 AM
  3. exiting program
    By ypramesh in forum C Programming
    Replies: 2
    Last Post: 04-01-2006, 02:27 PM
  4. Ask user to save file before exiting.
    By Bajanine in forum Windows Programming
    Replies: 3
    Last Post: 11-15-2004, 05:34 PM
  5. prevent exiting
    By Unregistered in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 12-12-2001, 01:57 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21