title: File to dynamic array in c
body: <p><strong>DISCLAIMER: I'm new to C.</strong></p>
  
  <p>What is the best way to convert every line in a .txt file (can be other file types too) to a dinamic calloc() array, and the other way around?</p>
  
  <p>In my file I have to following:</p>
  
  <pre><code>1 Hello
  2 18
  3 World
  4 15
  etc...
  </code></pre>
  
  <p>I want something like this in the array:</p>
  
  <pre><code>[0] Hello
  [1] 18
  [2] World
  [3] 15
  etc...
  </code></pre>
  
  <p>The code i have now:</p>
  
  <pre><code>FILE *file;
  file = fopen("test.txt", "r");
  int i = 0;
  
  //make dynamic calloc array
  //while line!= EOF
      //put line[i] into array
      //i++
      //realloc array, size +1
  
  fclose(file);
  </code></pre>
  
  <p>Is this way of doing this a good one or is there a better one?
  If someone could help me a little bit with the code I would be really thankful.</p>