title: getline line by line and then store entire lines in an array in C
body: <p>I'm trying to store every line separately in an array of strings. It doesn't work the way I've written it obviously all I'm getting when I try to print array[0] is the last line of the textfile. But when I print the variable "line" inside of the while loop I can print every single line in the text file but I can only seem to store the last line of the txt file.</p>
  
  <p>Is this possible to do? Or is this a limitation of getline..?</p>
  
  <pre><code>int main()
  {
    FILE * fp;
    char *line;
    ssize_t read;
    size_t bufsize = 32;
    int i=0;
  
    char **array;
  
    array = malloc(bufsize * sizeof(char));
    line = malloc(bufsize * sizeof(char)); 
    fp = fopen("testing.txt", "r"); 
  
    while ((getline(&amp;line, &amp;bufsize, fp)) != -1) { 
      printf("%s", line);
      array[i] = line;
      i++;
    } 
    fclose(fp);  
    printf("%s", array[0]);
  
    return 0;
  }
  </code></pre>