title: Getting "node has no member" error in GCC (c99) for basic trie structure
body: <p>I'm trying to implement a basic trie structure in plain old C, and I'm getting a "node has no member" error upon compilation.</p>
  
  <p>Here is my structure definition:</p>
  
  <pre><code>typedef struct node {
      bool word;
      struct node *alpharray[26];
  } node;
  </code></pre>
  
  <p>My attempts to initialize some nodes are as follows:</p>
  
  <pre><code>node *root = malloc(sizeof(node));
  node *nptr = malloc(sizeof(node));
  nptr = root;
  </code></pre>
  
  <p>The above code uses "iterator" as the pointer that will cycle through the given trie structure as it's being created. Here's how that works:</p>
  
  <pre><code>while (ch != '\n' &amp;&amp; !feof(fp))
  {
      //get the array index value for the current character (ch)
      //getCharNum() returns an int 0-25 corresponding to a slot for a node's alpharray
      int char_num = getCharNum(ch);
  
      //if a character has not been put in the given slot yet, make a new node and point    
      if (nptr-&gt;alpharray[char_num] == NULL)
      {
          node *newnode = malloc(sizeof(node));
          nptr-&gt;alpharray[char_num] = newnode;
          nptr = newnode;
      }
  
      //otherwise, move the main pointer to the next node in the chain of nodes
      else
      {
          nptr = nptr-&gt;alpharray[char_num];
      }
  
      //get the next character
      fread(&amp;ch, sizeof(char), 1, fp);
  }
  </code></pre>
  
  <p>The error I get when compiling repeats each time I try to access and/or change any given node attribute. I have also tried the *node.alpharray notation, which as I understand is the equivalent to the above because node will be dereferenced.</p>
  
  <p>I know it's probably something basic I'm overlooking, but I can't seem to find a solution anywhere. Ideas?</p>
  
  <p>Here is the compiler output:</p>
  
  <pre><code>gcc -ggdb -std=c99 -Wall -Werror   -c -o dictionary.o dictionary.c
  dictionary.c:30:15: error: expected ':', ',', ';', '}' or '__attribute__' before '=' token
  dictionary.c: In function 'load':
  dictionary.c:74:21: error: 'node' has no member named 'alpharray'
  dictionary.c:77:21: error: 'node' has no member named 'alpharray'
  dictionary.c:84:28: error: 'node' has no member named 'alpharray'
  dictionary.c:71:17: error: variable 'char_num' set but not used [-Werror=unused-but-set-variable]
  dictionary.c:93:16: error: 'node' has no member named 'word'
  cc1: all warnings being treated as errors
  
  make: *** [dictionary.o] Error 1
  </code></pre>