Thread: Doing something before exiting.

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    182

    Doing something before exiting.

    I want my program to do something before it exists when the user presses the close (X) key on the command prompt. Is it possible? If so, how can I do that? Thanks!

    P.S.: I'm on Windows
    Last edited by samus250; 10-28-2008 at 06:09 PM.

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    You can try registering a function with atexit() (I don't know whether clsoing the window calls exit or not).

  3. #3
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    You can't use signal in windows?
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  4. #4
    Registered User
    Join Date
    Jan 2008
    Posts
    182
    Thanks tabstop. atexit() seems to work fine and it does what I need.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. simple crash problem (exiting func)
    By te5la in forum C++ Programming
    Replies: 2
    Last Post: 09-16-2008, 03:15 PM
  2. Exiting the program.
    By Taka in forum C Programming
    Replies: 6
    Last Post: 10-14-2007, 09:24 AM
  3. Exiting windows through a C program.
    By Afro in forum C Programming
    Replies: 3
    Last Post: 06-23-2007, 08:29 AM
  4. Ask user to save file before exiting.
    By Bajanine in forum Windows Programming
    Replies: 3
    Last Post: 11-15-2004, 06:34 PM
  5. prevent exiting
    By Unregistered in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 12-12-2001, 02:57 PM