- Added error procedure.
This commit is contained in:
parent
7346247f62
commit
72e3eb6292
20
src/error.c
Normal file
20
src/error.c
Normal 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
6
src/error.h
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#ifndef ERROR
|
||||||
|
#define ERROR
|
||||||
|
|
||||||
|
void error (char *fmt, ...)
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue
Block a user