Terminating a program

This is a discussion on Terminating a program within the C++ Programming forums, part of the General Programming Boards category; I'm writing a program and I'm having problems getting it the program to close when a certain event happens. The ...

  1. #1
    Registered User
    Join Date
    Feb 2005
    Posts
    1

    Unhappy Terminating a program

    I'm writing a program and I'm having problems getting it the program to close when a certain event happens. The problem is because most sections of my code are within void functions, including the section involving termination of the program. I know return terminates a function but that only closes the program if its used it main.

    My question is simply this. How would I get a program to close out when a certain event (that is defined in a void) happens?

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,558
    Code:
    #include <cstdlib>
    
    // then later, inside some function
    exit( EXIT_FAILURE );
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. BOOKKEEPING PROGRAM, need help!
    By yabud in forum C Programming
    Replies: 3
    Last Post: 11-16-2006, 10:17 PM
  2. Can someome help me with a program please?
    By WinterInChicago in forum C++ Programming
    Replies: 3
    Last Post: 09-21-2006, 10:58 PM
  3. Terminating a GLUT program?
    By glo in forum Game Programming
    Replies: 4
    Last Post: 07-05-2006, 02:37 AM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM

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