title: Reading text file of unknown size
body: <p>I am trying to read in a text file of unknown size into an array of characters.
  This is what I have so far.</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;string.h&gt;
  
      int main()
      {
              FILE *ptr_file;
              char buf[1000];
          char output[];
              ptr_file =fopen("CodeSV.txt","r");
              if (!ptr_file)
                  return 1;   
  
          while (fgets(buf,1000, ptr_file)!=NULL)
              strcat(output, buf);
          printf("%s",output);
  
      fclose(ptr_file);
  
      printf("%s",output);
          return 0;
  }
  </code></pre>
  
  <p>But I do not know how to allocate a size for the output array when I am reading in a file of unknown size.
  Also when I put in a size for the output say n=1000, I get segmentation fault.
  I am a very inexperienced programmer any guidance is appreciated :)</p>
  
  <p>The textfile itself is technically a .csv file so the contents look like the following : 
  "0,0,0,1,0,1,0,1,1,0,1..."</p>