将数据从文件放入 C 中的数组

iNf*_*fas 5 c arrays file

这是我的代码。

#include <stdlib.h>
#include <stdio.h>

int main() {
    //Vars
    FILE *fp;
    char word[9999],
        *arrayOfWords[9999];
    int wordCount = 0, i;
    //Actions
    fp = fopen("data.txt", "r");
    if(fp != NULL) {
        while(!feof(fp)) {
            fscanf(fp, "%s", word);
            arrayOfWords[wordCount] = word;
            wordCount++;
        }
        for(i = 0; i < wordCount; i++) {
            printf("%s \n", arrayOfWords[i]);
        }
    puts("");
    } else {
        puts("Cannot read the file!");
    }
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

我正在尝试从文本文件中读取一些数据并将其存储到数组中。当我在循环中时一切都很好,但是当我离开那里时,数组中任何索引的任何值都填充了文件的最后一个字。谁能帮我找出我正在做的错误?

数据文件:

Hello there, this is a new file.
Run Code Online (Sandbox Code Playgroud)

结果:

file.
file.
file.
file.
file.
file.
file.
file.
Run Code Online (Sandbox Code Playgroud)

任何帮助,将不胜感激!