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






