/* Collection of code snippets by Arne Vajhøj */
/* (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) */
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>

void sighandl(int sig)
{
   if(sig==SIGINT)
   {
      printf("CTRL/C was pressed\n");
      exit(0);
   }
   if(sig==SIGSEGV)
   {
      printf("Illegal memory access was attempted\n");
      exit(0);
   }
}

int main()
{
   char buf[80],*p;
   signal(SIGSEGV,sighandl);
   signal(SIGINT,sighandl);
   printf("Press enter or CTRL/C\n");
   fgets(buf,sizeof(buf),stdin);
   p = NULL;
   *p = 'A';
   return 0;
}
