I take filenames as arguments of this function and I want to compare two txt files and replace some words in "article". But stack smashing detected error is occured at compiling. What is wrong in this code?
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);
}
}