⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 getword.c

📁 <<c语言接口与实现>>一书源码,此书无疑是一部经典的c语言书籍,只可惜翻译的质量很差
💻 C
字号:
static char rcsid[] = "$Id: H:/drh/idioms/book/RCS/table.doc,v 1.13 1997/10/27 23:10:11 drh Exp $";
#include <ctype.h>
#include <string.h>
#include <stdio.h>
#include "assert.h"
#include "getword.h"
int getword(FILE *fp, char *buf, int size,
	int first(int c), int rest(int c)) {
	int i = 0, c;
	assert(fp && buf && size > 1 && first && rest);
	c = getc(fp);
	for ( ; c != EOF; c = getc(fp))
		if (first(c)) {
			{
				if (i < size - 1)
					buf[i++] = c;
			}
			c = getc(fp);
			break;
		}
	for ( ; c != EOF && rest(c); c = getc(fp))
		{
			if (i < size - 1)
				buf[i++] = c;
		}
	if (i < size)
		buf[i] = '\0';
	else
		buf[size-1] = '\0';
	if (c != EOF)
		ungetc(c, fp);
	return i > 0;
}

⌨️ 快捷键说明

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