exit() ?

This is a discussion on exit() ? within the C++ Programming forums, part of the General Programming Boards category; hello, I have been trying to use exit() as a way to exit the program when it meets certain conditions...the ...

  1. #1
    smd
    smd is offline
    Registered User
    Join Date
    Jun 2002
    Posts
    43

    exit() ?

    hello,
    I have been trying to use exit() as a way to exit the program when it meets certain conditions...the complier I'm using is codewarrior...however whenever I use exit(), the error I get is: "undefined identifier 'exit' ", I have used exit() before in UNIX and it worked fine...is there a subtitute for exit(), or is it in some specific library that I need to include??...I have included
    iostream.h in my code... any help will be appreciated...thanks.

  2. #2
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,267
    #include <stdlib.h>
    or
    #include <cstdlib>
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

  3. #3
    smd
    smd is offline
    Registered User
    Join Date
    Jun 2002
    Posts
    43
    thanks....that did work....

  4. #4
    Just a Member ammar's Avatar
    Join Date
    Jun 2002
    Posts
    953

    Lightbulb

    I think you should include <cstdlib> and I Think that it takes an integer argument, as far as I know, exit(0) if it exits without an error and a non zero value for exiting with an error.

    Ammar.

  5. #5
    Registered User
    Join Date
    Jun 2002
    Posts
    44
    the exit() function uses DOS's exitcode,so its probably best to use return instead,unless you want to send a 0 exitcode,meaning no errors,or non-zero meaning an/some error(s)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Chat Program Help?
    By Paul22000 in forum Networking/Device Communication
    Replies: 9
    Last Post: 02-10-2009, 12:35 AM
  2. Odd memory leaks
    By VirtualAce in forum C++ Programming
    Replies: 11
    Last Post: 05-25-2006, 01:56 AM
  3. Replies: 1
    Last Post: 03-21-2006, 07:52 AM
  4. Dynamic array of pointers
    By csisz3r in forum C Programming
    Replies: 8
    Last Post: 09-25-2005, 03:06 PM
  5. Exit a function
    By MasterGBC in forum C Programming
    Replies: 3
    Last Post: 04-10-2003, 11:46 PM

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