| | |
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
Views: 550 | Replies: 7
| Thread Tools | Search this Thread |
Tag cloud for C
* api append array arrays bash binarysearch changingto char character cm copyanyfile copypdffile createcopyoffile createprocess() csyntax database directory drawing dynamic executable execv feet fgets file floatingpointvalidation fork frequency function getlogicaldrivestrin givemetehcodez global graphics gtkwinlinux histogram homework i/o ide include infiniteloop initialization input interest intmain() iso keyboard kilometer lazy license linked linkedlist linux list lowest matrix meter microsoft mqqueue mysql oddnumber odf open openwebfoundation overwrite pause pdf pointer pointers posix power program programming pyramidusingturboccodes read recursion recv recvblocked reversing scheduling segmentationfault send single socket socketprogramming spoonfeeding standard strchr string student suggestions system test testautomation testing unix urboc user whythiscodecausesegmentationfault win32api windowsapi






