In pset5, Speller won't load the large dictionary. Per the pset instructions, I seem not to have implemented my dictionary.c properly. Below are the beginning of my dictionary.c load section, and the gdb output from the problem area.

Thanks in advance for any help.

bool load(const char* dictionary)

        //open dictionary & confirm it exists
        FILE* file = fopen(dictionary, "r");
        if (file == NULL)       
            return false;

        //load dictionary's words
        char word[LENGTH + 1];        

      while (fscanf(file, "%s\n", word) != EOF)
       //increase dicionary word count by +1

(gdb) run text
Starting program: /home/jharvard/Dropbox/pset5/speller text

Breakpoint 1, main (argc=2, argv=0xbffff0e4) at speller.c:28
28      if (argc != 2 && argc != 3)
(gdb) n
38      double time_load = 0.0, time_check = 0.0, time_size = 0.0, time_unload = 0.0;
(gdb) n
41      char* dictionary = (argc == 3) ? argv[1] : DICTIONARY;
(gdb) n
44      getrusage(RUSAGE_SELF, &before);
(gdb) n
45      bool loaded = load(dictionary);
(gdb) n
46      getrusage(RUSAGE_SELF, &after);
(gdb) n
49      if (!loaded)
(gdb) n
51          printf("Could not load %s.\n", dictionary);
(gdb) n
Could not load /home/cs50/pset5/dictionaries/large.
52          return 1;
  • The code looks right to me, so I have some questions that may sound too basic or too obvious. Have you verified that the file /home/cs50/pset5/dictionaries/large exists? Does it have the correct permissions? Is it possible that it is currently locked (sometimes an edit program will lock a file when open for edit.) Have you tried copying the file to the local directory and explicitly adding it as a parameter to the speller when you run it? This will at least tell you that the program is working. Hope this helps.
    – Cliff B
    Commented May 4, 2015 at 18:32

1 Answer 1


I think it is because you dind't return any value if you actually loaded the dictionary. You should return true at the end of the load function and see how that goes.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .