title: C++ read numbers from file and store in vectors
body: <p>I am having trouble "undoing" this method, that dumps essentially a matrix of numbers of variable size into a text file:</p>
  
  <pre><code>void vectorToFile(char *name, vector&lt;vector&lt;double&gt;&gt;* a){
      FILE* fp = fopen(name, "w");
      for(int i=0;i&lt;a-&gt;size();i++){
          for(int j=0;j&lt;a-&gt;at(i).size();j++){
              fprintf(fp, "%f ", a-&gt;at(i).at(j));
          }
          fprintf(fp, "\n");
      }
      fclose(fp);
  }
  </code></pre>
  
  <p>I am having trouble implementing the reverse:</p>
  
  <pre><code>vector&lt;vector&lt;double&gt;&gt; fileToVector(char *name){ ??? }
  </code></pre>
  
  <p>I am guaranteed that the numbers in the file form a "rectangle", i.e. the sizes of inner vectors are all equal, but I don't know how to figure out the number of entries per row, and the number of columns.</p>
  
  <p>Can anyone point me in the right direction? Every example I found so far implements something much easier, with hardcoded size, or sizes given in first row (which I cannot afford to do unfortunately)</p>