Thread: Couple of Q's.....

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Sep 2003
    Posts
    135
    Originally posted by deadpoet
    There are 1000 diferent was to accomplish anything in C/C++, if one prefers exit over return, the fact still remains that you gave an int back to the operating system. I feel that return should be reserved for functions, methods, and such. When you exit a program you should indicate as such thus, my use of exit. I am exiting the program.

    However, if there is a solid reason as to why I should return instead of exit when I am leaving a program then I am all ears.
    In C++ the use of exit() is considered poor practice. Terminating the program using exit() doesn't invoke destructors for local objects. Better is to terminate with return via main() or throw an exception, the latter providing an opportunity for dealing with the condition that caused it.
    Last edited by Omnius; 02-21-2004 at 03:57 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Studying for Final, Couple Questions...
    By stewade in forum C Programming
    Replies: 4
    Last Post: 05-10-2004, 05:02 PM
  2. Pokemon talk and a couple useless stories
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 17
    Last Post: 02-01-2003, 03:49 PM
  3. Thought I'd registered last couple of months...
    By Grayson_Peddie in forum A Brief History of Cprogramming.com
    Replies: 17
    Last Post: 08-31-2002, 09:34 PM
  4. Couple Code Snippets
    By Unregistered in forum Game Programming
    Replies: 1
    Last Post: 01-22-2002, 02:23 AM
  5. Replies: 5
    Last Post: 11-13-2001, 04:38 PM