errorp.c

来自「数据格式检查算法」· C语言 代码 · 共 43 行

C
43
字号
/*********************************************************************
 *	Error Processing
 *********************************************************************/
#include <stdio.h>
#include <stdlib.h>

#include "GetData.h"
#include "types.h"

/*out**********************************************************
 *			Error messages					 
 **************************************************************/
void Error(short n, char *s1, char *s2)
{
    static char Messages=0;   /* 记录系统出错的次数 */

    printf("\nERROR:  ");
    switch(n) {
	   case 0: 
		    printf("cannot open file %s%s\n", s1, s2);
		    exit(1);
	   case 1:	
		    printf("':' expected after attribute name %s\n", s1);
		    break;
	   case 2:	
		    printf("unexpected eof while reading attribute %s\n", s1);
		    break;
       case 3: 
		    printf("attribute %s has only one value\n", s1);
		    break;
	   case 4: 
		    printf("case %d's value of '%s' for attribute %s is illegal\n", ItemNum+1, s2, s1);
		    break;
	   case 5: 
		    printf("case %d's class of '%s' is illegal\n", ItemNum+1, s2);
    }

    if ( ++Messages > 10 ) {
	   printf("Error limit exceeded\n");
	   exit(1);
    }
}

⌨️ 快捷键说明

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