Change
fn = open("word.txt", "rb");
to
fn = fopen("word.txt", "rb");
open
returns an int
, which is not a FILE*
. feof
and fscanf
expect a FILE*
not an int as its first parameter, that's the reason why feof()
and, if you remove it, fscanf()
segfaults.
And as others already noted, change fscanf(fn, "%s", &word)
to fscanf(fn, "%s", word)
.