title: How to find unknown number of rows and cols from input file?
body: <p>So the input file will look similar to this, it can be arbitrary..:</p>
  
  <pre><code>000001000101000
  010100101010000
  101010000100000
  </code></pre>
  
  <p>I need to be able to find how many rows and columns are in the input file before I can start reading the file into a 2d array and I don't know if this is the right way to do it:</p>
  
  <pre><code>char c;
  fin.get(c);
  COLS = 0;
  
  while ( c != '\n' &amp;&amp; c != ' ')
  {
      fin.get(c);
      ++COLS;
  }
  
  cout &lt;&lt; "There are " &lt;&lt; COLS &lt;&lt; " columns in this text file" &lt;&lt; endl;
  
  
  ROWS = 1;
  string line;
  while ( getline( fin, line ))
      ++ROWS;
  
  
  cout &lt;&lt; "There are " &lt;&lt; ROWS &lt;&lt; " rows in this text file" &lt;&lt; endl;
  </code></pre>
  
  <p>If this is not the right way to do it or there is a more simple way please help me out.</p>
  
  <p><strong>I ALSO CAN'T USE THE STRING LIBRARY</strong></p>