title: word counter 'forgetting' about already saved word
body: <p>The snippets below are from my program that gets words, then prints them with the number of occurences.</p>
  
  <p>It works almost fine except for it "forgots" that particular entry has been saved before and does NOT increment counter associated with it. </p>
  
  <pre><code>typedef struct {
      char *word;
      int occ;
  }
  words;
  words *data=NULL;
  
  int main(int argc, char **argv)
  {
      char *word;
      words *temp;
      int c,i,num;
      words *ptr = NULL;
  
      num=0;
  
      while(1)
      {
          c=fgetc(infile);
          if(c==EOF) break;
          if(!isalpha(c)) continue;
          else ungetc(c,infile);
          word=getword(infile);
  
          if(findword(word))
          {
  
              if(!(temp=realloc(data,sizeof(words)*(num+1))))
              { /* error handling */ }
              else
                  data=temp;
  
  
  
          }
          else
             free(word);
      }
  
      /* sort procedure here, irrelevant for the purpose of topic */
      for(i=0;i&lt;num;i++)
      {
          /*printf*/
      }
  
      return 0;
  
  }
  </code></pre>
  
  <p>What's wrong with that code?</p>
  
  <p>Thanks in advance!</p>