jsstrerr.c

来自「b tree how to operate on b tr」· C语言 代码 · 共 57 行

C
57
字号
/*JS***********************************************************************    Program : JSSTRERROR*    Language: ANSI-C*    Author  : Joerg Schoen*    Purpose : Get error string for internal error code.**************************************************************************/#ifndef lintstatic const char rcsid[] = "$Id: jsstrerr.c,v 1.2 1997/07/20 21:21:05 joerg Stab joerg $";#endif/*********     INCLUDES                                         *********/#include <stdio.h>#include <string.h>#include <jsconfig.h>#include <jssubs.h>#define Prototype extern/*********     PROTOTYPES                                       *********/Prototype const char    *jsStrError(int err);/*JS***********************************************************************************************************************************************/const char *jsStrError(int err)/************************************************************************/{  if(err == 0) return("No error");  if(JSErrors[0]) { /* ***  Read errors from file  *** */    FILE *fp;static char Buffer[100];    if((fp = fopen(JSErrors[0],"r")) == NULL) goto nomsg;    do {      if(fgets(Buffer,100,fp) == NULL) goto nomsg;    } while(err-- > 1);    fclose(fp);    /*  Delete trailing '\n'  */    if(Buffer[0]) Buffer[strlen(Buffer) - 1] = '\0';    return(Buffer);  }  return(JSErrors[err]);nomsg:  return("<FATAL: Error message not available>");}

⌨️ 快捷键说明

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