【问题标题】:im trying to make a spell checker using strcmp我正在尝试使用 strcmp 制作拼写检查器
【发布时间】:2023-03-05 16:28:02
【问题描述】:
while (exit!=true )
{
   input sprintf(thename, "person%d.txt", thecounter);
   searchfile=fopen(thename,"r");
   fscanf(searchfile,"%d%s%s%f%f\n",&theperson.id,theperson.firstname,theperson.lastname ,&theperson.sallary , &theperson.saving);    
   numfirst =strcmp(inputfirstname,theperson.firstname);
   numlast  = strcmp(inputlastname ,theperson.lastname);
   if ( numfirst == 0 || numlast == 0 ) 
}

到目前为止,如果我不使用循环并直接指向位置文件,我一直在尝试使其唯一有效。

我想搜索,尽管有条件,它仍然保持无限循环,顺便说一句,这不是完整的代码,因为我无法将整个模块粘贴到增量和 fclose 条件

【问题讨论】:

  • 首先代码不完整..
  • 该代码不适用于拼写检查。
  • 它不完整,因为我不知道如何将整个代码放在这里。问题是为什么这段代码是无限循环的。它有点像拼写检查器而不是 100% 拼写检查器认为基本思想是使用 strcmp 比较输入和文件之间的关系

标签: c file loops pointers spell-checking


【解决方案1】:

这是一个无限循环,因为(至少从您提供的代码来看)exit 始终为 false 并且永远不会设置为 true

【讨论】:

  • 我确实在 if 语句之后声明它只是在我尝试放置所有文件时它不适合
  • @albertcahyawan 那么你已经省略了代码中最关键的部分
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-07-02
  • 1970-01-01
  • 2012-07-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多