I have been coding in C for four years now. Any C user knows the segmentation fault error. And trust me, there cannot possibly be anything worse than seeing your program terminate with a seg fault message. It irritates me so much that in my B Tech Project program I have created a signal handler which catches the error and prints a happy message instead of the boring default message.
This is what I have done :
// Include signal.h for signal handling
#include <signal .h>
/**
* The function which is called upon a seg fault
*/
void SignalHandler(int sig) {
printf("\n\nHave a happy time debugging. Good luck
\n\n");
exit(-1);
return;
}
/**
* The main function. Declare the signal handler here.
*/
int main(int argc, char *argv[]) {
signal(SIGSEGV, SignalHandler);
/**
* Do whatever you want to
*/
return 0;
}
. I know this doesn’t do anything, but atleast I do not feel frustrated now.
Popularity: 1% [
27
MAR

About the Author:
Nitwit, Blubber, Oddment, Tweak !!