bool.c

来自「一个C语言写的快速贝叶斯垃圾邮件过滤工具」· C语言 代码 · 共 44 行

C
44
字号
/* $Id: bool.c,v 1.4 2004/03/03 16:29:12 relson Exp $ *//*****************************************************************************NAME:   bool.c -- functions to support the "bool" type.AUTHOR:   David Relson <relson@osagesoftware.com>******************************************************************************/#include "common.h"#include <ctype.h>#include <stdlib.h>#include "bool.h"bool str_to_bool(const char *str){    char ch;    while (isspace((unsigned char)*str))	   str += 1;    ch = toupper((unsigned char)*str);    switch (ch)    {    case 'Y':		/* Yes */    case 'T':		/* True */    case '1':	return (true);    case 'N':		/* No */    case 'F':		/* False */    case '0':	return (false);    default:	fprintf(stderr, "Invalid boolean value - %s\n", str);	exit(EX_ERROR);    }    return (0);}

⌨️ 快捷键说明

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