c - 在拼写校正器中检测到堆栈粉碎
问题描述
我将文件名作为这个函数的参数,我想比较两个 txt 文件并替换“文章”中的一些单词。但是在编译时发生堆栈粉碎检测错误。这段代码有什么问题?
void fix_spelling_error(char* dictionary, char* article)
{
int articleCursor=0, compare, i=0, j, checkSpeller=0, ch;
char word[100], sub[100];
FILE *reader, *changer;
reader = fopen(dictionary, "r");
changer = fopen(article, "r+");
if (changer != NULL && reader != NULL)
{
while(!feof(changer)
fscanf(changer, "%s", word);
while (!feof(reader))
{
fscanf(reader, "%s", sub);
compare = strcmp(word, sub);
if (compare == -1)
{
articleCursor = strlen(word);
fseek(changer, -articleCursor, SEEK_CUR);
strcpy(word, sub);
fprintf(changer, "%s", word);
}
}
fclose(reader);
fclose(changer);
}
}
解决方案
推荐阅读
- sql - PostgreSQL如何在where运算符之后过滤
- sqlite - 带有任务计划程序的 Sqlite3 或使用命令提示符计划任务
- r - igraph中最低的共同祖先
- python - Django 表单不呈现。
- javascript - 如何删除旧的 SVG 元素,然后用新元素替换它?
- python-3.x - 如何使用列表单元格从列表中查看 DataFrame
- javascript - 无法从插槽子组件中的父级访问数据属性
- android - 如何在不指定密钥的情况下从 firebase 检索数据?
- regex - 正则表达式匹配单词后跟空格或空
- javascript - Netlify Lambda 函数不从 POST 请求中获取参数(使用 fetch / axios)