title: C - extracting words from string
body: <p>I'm fairly new to C and therefore encountering quite a bit of confusion with using pointers. </p>
  
  <p>I'm trying to extract words from a string of ASCII characters. 
  For instance, if I have the string @@Hello..world>>, I want to get the words "Hello" and "world" out of the string and add them to my linked list. </p>
  
  <p>A word is defined as any sequence of letters, and each word is at most 64 bytes. Also, any character where the function isspace() returns a non-zero value is considered whitespace. </p>
  
  <p>Basically, I'm scanning in the strings from a file using fscanf, then for each string calling my function read_words(char *s) to get the proper words out of the string and add them to my linked list for further use. </p>
  
  <p>Here is my code which seems to be throwing an error that has to do with a pointer. </p>
  
  <pre><code>struct node {
      char *val;
      struct node *next;
      int count;
  } *words = NULL;
  
  
  void read_words(char *s)
  {
      struct node *tmp;
      char word[64+1];
      int i, check, wordStarted = 0, count = 0;
  
      for (i = 0; s[i] != '\0'; i++)
      {
              if ((isspace(s[i]) != 0) || !isalpha(s[i]))
              {
                      if (wordStarted == 1)
                      {
                              check = check_list(word);
                              if (check != 1) {
                                      word[count] = '\0';
                                      tmp = malloc(sizeof(struct node));
                                      tmp-&gt;val = word;
                                      tmp-&gt;count = 1;
                                      tmp-&gt;next = words;
                                      words = tmp;
                              }
                              count = 0;
                              wordStarted = 0;
                      }
              }
              else
              {
                      word[count++] = s[i];
                      wordStarted = 1;
              }
      }
  
  }
  </code></pre>
  
  <p>Any help with this would be much appreciated!</p>
  
  <p>Thank you!</p>