title: C - How do i read all lines of a file
body: <p>Im unsure how to read all the lines of a file, atm it only reads the first line of the code in the text file. Can someone show me how to make it read all the lines?</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  
  int main(int argc, char **argv)
  {
  
      FILE *fp;
      fp = fopen("specification.txt", "r");
  
      char ** listofdetails; 
  
      listofdetails = malloc(sizeof(char*)*6);
      listofdetails[0] = malloc(sizeof(char)*100);
  
      fgets(listofdetails[0], 100, fp);
  
  
      /*strcpy(listofdetails[0], "cars");*/
  
      printf("%s \n", listofdetails[0]);
  
  
      free(listofdetails[0]);
      free(listofdetails);
      fclose(fp);
  
      return 0;
  }
  </code></pre>
  
  <p>MY text file:</p>
  
  <pre><code>10X16 de4 dw9 ds8 g8,7 m3,4 h6,5 p2,2 
  10X16 de4 dw9 ds8 g8,7 m3,4 h6,5 p2,2
  10X16 de4 dw9 ds8 g8,7 m3,4 h6,5 p2,2
  </code></pre>