Skip to content

Instantly share code, notes, and snippets.

@nvictor
Last active February 20, 2020 23:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nvictor/07f35c7d827599e09dda1a5786384e7f to your computer and use it in GitHub Desktop.
Save nvictor/07f35c7d827599e09dda1a5786384e7f to your computer and use it in GitHub Desktop.
Fatal and error functions
#include <stdarg.h> # va_list, va_start, va_end
#include <stdio.h> # vprintf
#include <stdlib.h> # exit
void fatal(const char *format, ...) {
va_list args;
va_start(args, format);
printf("Fatal: ");
vprintf(format, args);
printf("\n");
va_end(args);
exit(1);
}
void error(const char *format, ...) {
va_list args;
va_start(args, format);
printf("Error: ");
vprintf(format, args);
printf("\n");
va_end(args);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment