Listing 4 fatal.c — prints an error message and then exits the program

/* fatal.c:  Exit program with an error message */

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>

void fatal(char *fmt, ...)
{
   va_list args;
   
   if (fmt != NULL && strlen(fmt) > 0)
   {
      va_start(args,fmt);
      vfprintf(stderr,fmt,args);
      va_end(args);
   }
   exit(EXIT_FAILURE);
}
/* End of File */