Hello! I was making simple programm for word search, but found an error I can't explain.
This code piece of code that causes it is:
if (word==search){
printf("\n %i %s ", i, word);
i++;
}
I can only suppose that the compiler(visual studio express) dosn't support such comparisions of sth should be done about the array's sizes.
#include <stdio.h>
#include <conio.h>
void main() {
FILE *f;
int i = 1;
char word[20];
char name[20];
char search[20];
printf("Please input the mane of the file: ");
scanf("%s", name);
if((f=fopen(name, "r"))==NULL) {
printf("Error");
getch();
return;
}
printf ("\nPlease input the word for search: ");
scanf("%s", search);
while (!feof(f)) {
fscanf(f, "%s", word);
if (word==search){
printf("\n %i %s ", i, word);
i++;}
}
fclose(f);
getch();
}