got_c.c

来自「NIST Handwriting OCR Testbed」· C语言 代码 · 共 45 行

C
45
字号
/*# proc: got_c - Gets the next character of a file, also telling the number# proc:         of the line it was on.Input arg:  fp: FILE pointer.Output args:  thechar: The next character.  linenum: Line number (starting at 1) of the character.Return value:  TRUE: Got a character.  FALSE: Reached end-of-file.  The character returned in the preceding    call was the last one in the file.*/#include <stdio.h>#include <string.h>#include <mlp/defs.h>chargot_c(fp, thechar, linenum)FILE *fp;char *thechar;int *linenum;{  static char line[500], *p;  static int num_buffered = 0, ln = 0;  if(num_buffered == 0) {    if(!fgets(line, 500, fp)) {      num_buffered = ln = 0;      return FALSE;    }    ln++;    p = line;    num_buffered = strlen(line);  }  *thechar = *p++;  num_buffered--;  *linenum = ln;  return TRUE;}

⌨️ 快捷键说明

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