diff options
Diffstat (limited to 'eprintf.c')
| -rw-r--r-- | eprintf.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/eprintf.c b/eprintf.c new file mode 100644 index 0000000..386293b --- /dev/null +++ b/eprintf.c @@ -0,0 +1,27 @@ +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> + +#include "eprintf.h" + +void +eprintf(const char *fmt, ...) { + va_list args; + + va_start(args, fmt); + fprintf(stderr, "error: "); + vfprintf(stderr, fmt, args); + fprintf(stderr, "\n"); + va_end(args); + exit(1); +} + +void weprintf(const char *fmt, ...) { + va_list args; + + va_start(args, fmt); + fprintf(stderr, "warning: "); + vfprintf(stderr, fmt, args); + fprintf(stderr, "\n"); + va_end(args); +} |