title: Two-dimensional vector printing
body: <p>I've got a two-dimension string vector that I need to print out. The whole program should read a line from a txt file, store each word from it as a different element and then push the &quot;word vector&quot; into a vector that contains for example 100 lines. I've got everything going, but the problem comes out when I have to print the vector. Every line can have a different number of words, ex:</p>
  <blockquote>
  <p>I like cake</p>
  <p>a lot.</p>
  </blockquote>
  <p>So I can't use:</p>
  <pre><code>for (int i = 0; i &lt; 2; i++)
  {
      for (int j = 0; j &lt; 3; j++)
      {
          cout &lt;&lt; vec[i][j];
      }
  }
  </code></pre>
  <p>because the second line doesn't contain 3 elements and the program closes.<br />
  Any idea how to do it? Note: my lecturer doesn't accept C++11, so a solution based on C++98 would be appreciated. This is my function:</p>
  <pre><code>void readline(vector&lt;vector&lt;string&gt; &gt;&amp; lines, int size)
  {
      vector&lt;string&gt; row;
      string line, word;
      fstream file;
      istringstream iss;
      int i;
  
      file.open(&quot;ticvol1.txt&quot;, ios::in);
      for (i = 0; i &lt; size; i++)
      {
          getline(file, line);
          iss.str(line);
          while (iss &gt;&gt; word) row.push_back(word);
          lines.push_back(row);
      }
  }
  </code></pre>