title: CS50 Week5 Speller error1
body: <p>I wrote this and it doesn't compile successfully, but I don't know why.  Can you help?</p>
  <pre><code>// Implements a dictionary's functionality
  
  #include &lt;cs50.h&gt;
  #include &lt;ctype.h&gt;
  #include &lt;stdbool.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  #include &lt;strings.h&gt;
  #include &lt;stdlib.h&gt;
  
  #include &quot;dictionary.h&quot;
  
  // Represents a node in a hash table
  typedef struct node
  {
      char word[LENGTH + 1];
      struct node *next;
  }
  node;
  
  // TODO: Choose number of buckets in hash table
  const unsigned int N = (LENGTH+1 * 'z');
  
  // Hash table
  int total_words = 0;
  node *table[N];
  // [nn3, new_node2, nn4, ...]
  //          |
  //      new_node
  
  // Returns true if word is in dictionary, else false
  bool check(const char *word)
  {
      // Obtain the hash index
      int index = hash(word);
  
      node *cursor = table[index];
      while (cursor != NULL)
      {
          if (strcasecmp(cursor-&gt;word, word) == 0)
          {
              return true;
          }
          cursor = cursor-&gt;next;
      }
  
      return false;
  }
  
  // Hashes word to a number
  unsigned int hash(const char *word)
  {
      int sum = 0;
      for(int i = 0; i &lt; strlen(word); i++)
      {
          sum += tolower(word[i]);
      }
      return (sum % N);
  }
  
  // Loads dictionary into memory, returning true if successful, else false
  bool load(const char *dictionary)
  {
      // Open the dictionary
      FILE *file = fopen(dictionary, &quot;r&quot;);
      if (file == NULL)
      {
          return false;
      }
  
      // Read strings from file one at a time
      char word[LENGTH + 1];
      while(fscanf(file, &quot;%s&quot;, word) != EOF)
      {
          // Create a new node
          node *new_node = malloc(sizeof(node));
          if(new_node == NULL)
          {
              return false;
          }
  
          // We can copy over the word to the node
          strcpy(new_node-&gt;word, word);
          new_node-&gt;next = NULL;
  
          // Obtain hashin index
          int index = hash(word);
          if(table[index] == NULL)
          {
              table[index] = new_node;
          }
          else
          {
              new_node-&gt;next = table[index];
              table[index] = new_node;
          }
          total_words++;
      }
      fclose(file);
      return true;
  }
  
  // Returns number of words in dictionary if loaded, else 0 if not yet loaded
  unsigned int size(void)
  {
      return total_words;
  }
  
  // Unloads dictionary from memory, returning true if successful, else false
  bool unload(void)
  {
      // Free the linked list
      for(int i = 0; i &lt; N; i++)
      {
          node *head = table[i];
          node *cursor = head;
          node *tmp = head;
  
          while(cursor != NULL)
          {
              cursor = cursor-&gt;next;
              free(tmp);
              tmp = cursor;
          }
      }
      return true;
  }
  </code></pre>
  <p>I got every time this error:</p>
  <pre class="lang-none prettyprint-override"><code>/usr/bin/ld: /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crt1.o: in function `_start':
  (.text+0x24): undefined reference to `main'
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  make: *** [&lt;builtin&gt;: dictionary] Error 1
  </code></pre>
  <p>After a long time researching, I found nothing to fix it.  Can someone help me?</p>