testwordexistornot.h
来自「一个简单的词法分析程序。是编译原理的部分课程设计。因为时间有限。未能完成全部。如」· C头文件 代码 · 共 28 行
H
28 行
/*=================================================
** 2005-8-25 **
** 检测一个常量的值是否存在在文件中 **
** lizhu zhang **
==================================================*/
/*=============================================
**函数用能:检测一个常量的值是否存在在文件中
**参数说明:[in]pString:接受传入的字符串
**返回值 : 在文件中返回1,否则返回0,文件操作失败返回-1
**===========================================*/
int FExistOrNot(const char *pString,const char *pFileName)
{
char testWord[2048];
fstream file;
file.open(pFileName,ios::in);
if(!file)
{
return -1;
}
//操作成功
while(!file.eof())
{
file.getline(testWord,2048);
if(strcmp(testWord,pString)==0)
return 1;
}
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?