- Added error procedure.

This commit is contained in:
ccremers 2004-06-12 14:20:07 +00:00
parent 7346247f62
commit 72e3eb6292
2 changed files with 26 additions and 0 deletions

20
src/error.c Normal file
View File

@ -0,0 +1,20 @@
#include <stdio.h>
#include <stdarg.h>
#include "error.h"
//! Print error message and die.
/**
* Adapted from [K&R2], p. 174
* Input is comparable to printf, only end of line is not required.
*/
void error (char *fmt, ...)
{
va_list args;
va_start (args, fmt);
fprintf (stderr, "error: ");
vprintf (stderr, fmt, args);
fprintf (stderr, "\n");
va_end (args);
exit(1);
}

6
src/error.h Normal file
View File

@ -0,0 +1,6 @@
#ifndef ERROR
#define ERROR
void error (char *fmt, ...)
#endif