title: Extract string from txt file in C
body: <p>I have to extract every &quot;Artykuł&quot; from a txt file and number of line with that string. When I try to compile my program I have error: &quot;invalid initializer char str[]=line;&quot; so I don't know how should I assign every word separately from each line to a char table.</p>
  <pre><code>#define _GNU_SOURCE
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #define TRUE 1
  
  int getWords(char *base, char target[10][20])
  {
      int n=0,i,j=0;
      
      for(i=0;TRUE;i++)
      {
          if(base[i]!=' '){
              target[n][j++]=base[i];
          }
          else{
              target[n][j++]='\0';//insert NULL
              n++;
              j=0;
          }
          if(base[i]=='\0')
              break;
      }
      return n;
      
  }
  int main()
  {
    FILE * fp;
      char * line = NULL;
      size_t len = 0;
      ssize_t read;
  
      fp = fopen(&quot;dyrekt.html&quot;, &quot;r&quot;);
      if (fp == NULL)
          exit(EXIT_FAILURE);
          while ((read = getline(&amp;line, &amp;len, fp)) != -1) {
      int n; //number of words
      int i; //loop counter 
      char str[]=line;
      char arr[10][20];
      
      n=getWords(str,arr);
      
      for(i=0;i&lt;=n;i++)
          printf(&quot;%s\n&quot;,arr[i]);
      
      return 0;
  }
  fclose(fp);
      if (line)
          free(line);
      exit(EXIT_SUCCESS);
      }
  </code></pre>