title: read data from text file and store it in 2D vector using c++ language
body: <p>I am trying to read the data from the text file to the global 2D vector 'matrix
  The file content will be like :</p>
  <blockquote>
  <p>8, 3</p>
  <p>1, 6, 2</p>
  <p>9, 2, 5</p>
  <p>1, 5, 25</p>
  <p>7, 4, 25</p>
  </blockquote>
  <p>I could not figure out what is my mistake. my code store just the first row.</p>
  <pre><code>#include &lt;iostream&gt;
  #include&lt;fstream&gt;
  #include&lt;algorithm&gt;
  #include&lt;vector&gt;
  #include &lt;sstream&gt;
  #define EXIT_FILE_ERROR (1)
  #define EXIT_UNEXPECTED_EOF (2)
  #define EXIT_INVALID_FIRSTLINE (3)
  #define MAXLINE (10000)
  
  std::vector&lt; std::vector&lt;int&gt; &gt; matrix;
  int main(int argc, const char * argv[])
  {
      FILE *fp;
  
      std::string sFileName = &quot;Matrix1.txt&quot;;
      std::ifstream fileStream(sFileName);
      if (!fileStream.is_open())
      {
          std::cout &lt;&lt; &quot;Exiting unable to open file&quot; &lt;&lt; std::endl;
          exit(EXIT_FILE_ERROR);
      }
  
      std::string line;
  
      while ( getline (fileStream,line) )
      {
          std::stringstream ss(line);
          std::vector&lt;int&gt; numbers;
          std::string v;
          int value;
          while(ss &gt;&gt; value)
          {
              numbers.push_back(value);
              std::cout &lt;&lt; value &lt;&lt; std::endl;
          }
          matrix.push_back(numbers);
      }
  
      fileStream.close();
  
      if ((fp = fopen(sFileName.c_str(), &quot;r&quot;)) == NULL)
      {
          std::cout &lt;&lt; &quot;Exiting unable to open file&quot; &lt;&lt; std::endl;
          exit(EXIT_FILE_ERROR);
      }
      return 0;
  }
  </code></pre>
  <p>can some one tell me what is my mistake ?</p>