1

I'm writing this using Xcode on my mac.

The file is definitely the correct location, and it opens it fine. That's not the problem.

I'm aiming to get a text file of words to be read in, and stored in the array list for future use, so the array acts as a dictionary.

However no cigar. Any help would be great!

#define MAX_WORDS 300000
#define MAX_BUFFER 50

int create_dictionary(void) {

    FILE *fp = fopen("/Users/numberjak/Documents/Home/Projects/Python/anagram/words.txt", "r");

    if (fp == NULL) {
        printf("ERROR: File not found\n");
        return 1;
    }

    char list[MAX_WORDS][MAX_BUFFER];

    int i = 0;

    while (fgets(list[i], MAX_BUFFER, fp) != NULL) {
        printf(list[i]);
        i++;
    }

    fclose(fp);

    return 0;
}
numberjak
  • 1,065
  • 4
  • 13
  • 28

0 Answers0