| | |
execute some code just before stopping program using CTRL-C
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
I'm not exactly sure what you mean, but as CTRL-C is used to terminate your program I doubt any code will be allowed to run.
And she said "Let there be light" and on the seveth day Windows booted.
And the crowds screamed in terror and cowered in fear for Microsoft had approached.
From the testament of 10011101
And the crowds screamed in terror and cowered in fear for Microsoft had approached.
From the testament of 10011101
You could try signal():
C Syntax (Toggle Plain Text)
#include <stdio.h> #include <signal.h> void cleanup(int unused) { printf("Cleaning up\n"); exit(-1); } int main() { signal(SIGINT, cleanup); for (;;) /* Ctrl-C to exit */ ; }
As nucleon illustrated above it will depend on the operating system. His code is *nix only and possily MAC. For MS-Windows, see this article
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
![]() |
Other Threads in the C Forum
- Previous Thread: student grading system
- Next Thread: anyone..plz help me how to do this assingment
| Thread Tools | Search this Thread |
Tag cloud for C
adobe ansi api array arrays bash binarysearch centimeter char convert copyanyfile copypdffile cprogramme createcopyoffile createprocess() csyntax directory dynamic fflush file fork frequency getlasterror givemetehcodez global graphics gtkgcurlcompiling hardware highest homework i/o ide inches infiniteloop initialization interest kilometer km lazy linked linkedlist linux linuxsegmentationfault list locate logical_drives match matrix meter microsoft motherboard multi mysql open opendocumentformat opensource openwebfoundation owf pattern pdf performance pointer pointers posix power problem probleminc program programming pyramidusingturboccodes read recursion recv repetition scanf scheduling segmentationfault send shape single socketprograming socketprogramming spoonfeeding stack standard strchr string strings structures suggestions system systemcall test testautomation unix user voidmain() wab win32api windows.h






