title: C++ Reading from a text file into a const char array
body: <p>I want to read in lines from a text file into a 2-d char array but without the newline character.</p>
  
  <p>Example of .txt: </p>
  
  <pre><code>TCAGC
  GTAGA
  AGCAG
  ATGTC
  ATGCA
  ACAGA
  CTCGA
  GCGAC
  CGAGC
  GCTAG
  </code></pre>
  
  <p>...</p>
  
  <p>So far, I have:</p>
  
  <pre><code>ifstream infile;
  infile.open("../barcode information.txt");
  string samp;
  getline(infile,samp,',');
  BARCLGTH = samp.length();
  NUMSUBJ=1;
  while(!infile.eof())
  {
  getline(infile,samp,',');
  NUMSUBJ++;
  }
  infile.close();  //I read the file the first time to determine how many sequences
                   //there are in total and the length of each sequence to determine
                   //the dimensions of my array. Not sure if there is a better way?
  ifstream file2;
  file2.open("../barcode information.txt");
  char store[NUMSUBJ][BARCLGTH+1];
  
      for(int i=0;i&lt;NUMSUBJ;i++)
      {
          for(int j=0;j&lt;BARCLGTH+1;j++)
          {
          store[i][j] = file2.get();
          }
      }
  </code></pre>
  
  <p>However, I do not know how to ignore the newline character. I want the array to be indexed so that I can access a sequence with the first index and then a specific char within that sequence with the second index; i.e. store[0][0] would give me 'T', but I do not want store[0][5] to give me '\n'.</p>
  
  <p>Also, as an aside, store[0][6], which I think should be out of bounds since BARCLGTH is 5, returns 'G',store[0][7] returns 'T',store[0][8] returns 'A', etc. These are the chars from the next line. Alternatively, store[1][0],store[1][1], and store[1][2] also return the same values. Why does the first set return values, shouldn't they be out of bounds?</p>