title: List element instead of array C
body: <p>I have a function that works perfectly. The user types the word and the keyword. In the keyword instead some letters it can be used '?' meaning any random letter, '*' meaning any random amount of letters at the end and [x,y,z] meaning the letter could be x or y or z, then the functions checks if the words match. Here's how it looks like:</p>
  
  <pre><code>int MatchWord(char *Word, char *Sequence)
  
  {
  
  int i = 0;
  int j = 0; 
  int k = 0;
  int LastChar = 0;
  int CharMatch = 0;
  char SpecifiedChars[20];
  while(Word[i]!='\0' &amp;&amp; Sequence[j]!='\0')
  {if(isalpha(Sequence[j]))
      {
          if(Word[i]!=Sequence[j])
          {return 0;}
          i++;
          j++;
      }
  
      if(Sequence[j] == '?')
      {
          i++;
          j++;
      }
  
      if(Sequence[j] == '[')
  
      {
  
          j++;
          while(Sequence[j]!= ']')
  
          {
              if(isalpha(Sequence[j]))
              {
                  SpecifiedChars[LastChar] = Sequence[j];
                  LastChar++;
                  j++;
              }
              else
              {j++;}
          }
          j++;
          for(k = 0 ; k &lt;= LastChar ;k++)
          {
              if(SpecifiedChars[k]==Word[i])
              {CharMatch = 1;}
              SpecifiedChars[k] = ' ';
          }
          SpecifiedChars[0] = '\0';
          LastChar = 0;
          if(!CharMatch)
          {return 0;}
          i++;
      }
      if(Sequence[j] == '*')
      {
          j++;
          while(Word[i]!='\0')
          {i++;}
      }
  }
  return 1;
  }
  
  
  int main()
  {
  char word[30], keyword[30];
  printf("Type the word: \n");
  scanf("%s",word);
  printf("Type the key: \n");
  scanf("%s",keyword);
  if(MatchWord(word,keyword))
  {
      printf("\nWords match");
  }
  else
  {
      printf("\nWords don't match");
  }
  return 0;
     }
  </code></pre>
  
  <p>But I have to change it that instead of letting user type the first word, it checks the words in base I have in file txt. They're in structure:</p>
  
  <pre><code>typedef struct bazaslowek                                
      {
          char *word1;
          char *category;
          struct bazaslowek* next;
      } baza;
  </code></pre>
  
  <p>And that's how I put them on the list, which also works perfectly:</p>
  
  <pre><code>char word1[30];
  char category[20];
  FILE *fp;
  if ((fp = fopen("bazaslow.txt", "r"))==NULL)
      {printf("Error!");
      exit(EXIT_FAILURE);}
  else
      {
      while(!feof(fp))
          {
          fscanf(fp,"%s %s \n", word1, category);
          baza *wsk = *head;
          baza *new = malloc (sizeof(baza));
          new -&gt; next = NULL;
          new -&gt; word1 = strdup(word1);
          new -&gt; category = strdup(category);
          if(wsk == NULL)
              {
              new -&gt; next = *head;
              *head = new;
              }
          else
              {
              while(wsk -&gt; next != NULL)
              wsk = wsk -&gt; next;
              wsk -&gt; next = new;
              }
          }
      }
  fclose(fp);
  </code></pre>
  
  <p>I tried putting everything in a loop so while <code>wsk-&gt;next!=NULL</code> it checks if the <code>keyword</code> matches the <code>word1</code>, if yes it printfs it and checks another word, if not it just goes to the another word on the list without printf. Sadly I fail miserably here, as it usually doesn't printf anything at all or printfs all the words, doesn't matter if they match or not. Could anybody tell me how should it look like please?</p>