err_exit.c

来自「C语言库函数的源代码,是C语言学习参考的好文档。」· C语言 代码 · 共 34 行

C
34
字号
/* +++Date last modified: 05-Jul-1997 */

/*
**  ERR_EXIT.C - A generic fatal error-handler by Dave Schaumann
*/

#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include "errors.h"

void ErrExit(char *fmt, ...)
{
      va_list ap;

      va_start(ap, fmt) ;
      vfprintf(stderr, fmt, ap);
      fputc('\n', stderr);
      exit(EXIT_FAILURE);
}

#ifdef TEST

main()
{
      int x = 1, y = -1;

      if (x != y)
            ErrExit("Found x = %d, y = %d; Expected them to be equal!", x, y);
      return EXIT_SUCCESS;
}

#endif /* TEST */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?