title: Not getting the output I want
body: <p>I am trying to write a c++ program to read a txt file containing data (122X300 matrix - tab delimited matrix) into my code and get it to display. The following is the code I wrote after referring extensively to google and many similar questions on this site. On running the code, I do not get any errors, however it does give me huge list of numbers which I cant seem to make any sense of. The following is the code: Any help would be great. I do not know where I am going wrong. Thanks. </p>
  
  <p>DID some changes after considering the comment below by @ZekeMarsh, the problem now is that my text data is like:</p>
  
  <p><a href="http://i.stack.imgur.com/FWP6S.png" rel="nofollow">Data Matrix Snapshot</a></p>
  
  <p>The output I am getting is this:</p>
  
  <p><a href="http://i.stack.imgur.com/Lz7Cf.png" rel="nofollow">Output of Code</a></p>
  
  <p>The row counter does not move over to the next row,instead continues in the same row after incrementation....No idea why. The code modified is as follows:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;string&gt;
  #include &lt;conio.h&gt;
  
  using namespace std;
  
  int main(){
  
  int HEIGHT = 3;
  
  int WIDTH = 2;
  int array_req[HEIGHT][WIDTH];
  string userinputprompt, filename;
  
  userinputprompt = "Data Filename: ";
  
  cout&lt;&lt;userinputprompt&lt;&lt;endl;
  getline(cin,filename);
  ifstream inputfile;
  
  inputfile.open(filename.c_str());
  
  for(int i=0; i&lt;HEIGHT; i++)
  {
      for(int j=0; j&lt;WIDTH; j++)
      {
          /*if(!(inputfile&gt;&gt;array_req[i][j])) 
          {
              cerr&lt;&lt;"Error";
              break;
          }
          else if(!inputfile) // its error.. , can use a cerr here...
          {
              cerr&lt;&lt;"Error";
              break;
          }
          else*/
              inputfile&gt;&gt;array_req[i][j];
              cout&lt;&lt;i&lt;&lt;","&lt;&lt;j&lt;&lt;"--&gt;"&lt;&lt;array_req[i][j]&lt;&lt;endl;
      }
  
          /* This is not needed, read above comment
          else
          {
              inputfile &gt;&gt; array_req[i][j];
          }*/
      }
  
  for(int p=0; p&lt;HEIGHT; p++)
  {
      for(int q=0; q&lt;WIDTH; q++)
      {
          cout&lt;&lt;array_req[p][q]&lt;&lt;" ";
      }
      cout&lt;&lt;"\n";
  }
  
  inputfile.close();
  getchar();
  return 0;
  
  }
  </code></pre>
  
  <p>.
  EDITED CODE - The output array is a null matrix. Please help. What is wrong in  the code ..compiles correctly. Trying to read line by line using getline and stringstream based on a lot of examples I read here..still not working.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;string&gt;
  #include &lt;conio.h&gt;
  #include &lt;sstream&gt;
  #include &lt;stdlib.h&gt;
  
   const int HEIGHT = 3;
  
    const int WIDTH = 4;
  
   const int BUFFSIZE = 10000;
  
   using namespace std;
  
  int main(){
  
  int array_req [HEIGHT][WIDTH];
  
  char buff[BUFFSIZE];
  
  string userinputprompt, filename;
  
  userinputprompt = "COLORDATA FILENAME: ";
  
  cout&lt;&lt;userinputprompt&lt;&lt;endl;
  
  getline(cin,filename);
  
  ifstream inputfile;
  stringstream ss;
  inputfile.open(filename.c_str());
  
  for (int i=0; i&lt;HEIGHT; i++)
      {
          inputfile.getline(buff,BUFFSIZE,'\n');
  
          ss&lt;&lt;buff;
  
              for(int j=0;j&lt;WIDTH; j++)
          {
             ss.getline(buff,1000,'\n');
  
             array_req[i][j]=atoi(buff);
  
          }
          ss&lt;&lt;"";
          ss.clear();
      }
  
  for(int p=0; p&lt;HEIGHT; p++)
  {
      for(int q=0; q&lt;WIDTH; q++)
      {
          cout&lt;&lt;array_req[p][q]&lt;&lt;" ";
      }
      cout&lt;&lt;"\n";
  }
  
  inputfile.close();
  getchar();
  return 0;
  </code></pre>
  
  <p>}</p>