HELP, assignment due in a few hours - Stuck

So i have this .dat file that looks like this kind of:
1101010101
1101101000
0101000110
1000101001
1110011111
1000011100
0100100110
1101000011
1001001000
...
with a whole bunch of 10 digit binary codes. I am trying to read in from that file and store what I see in a corresponding 2d array. With my code, my output looks like this:
1101010101
101101000

101000110

000101001
...
The first row works great, but then i start losing the first bit from each row and it starts doing weird things with the return spacing. I'm not sure what I'm doing wrong! Any help is greatly appreciated as I cannot finish this assignment without getting this step right ;;

Thanks!


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
  /******************************************
*     library includes 
******************************************/
#include <iostream>
#include <iomanip> 
#include <cstdlib>
#include <fstream>
#include <string>
 
/******************************************
*     pre-processor
******************************************/
using namespace std;
 
 
int main(int argc, const char * argv[])
 
{
    char codesTable[300][10];
    char input2;
    int j = 0;
    ifstream indata; // indata is like cin
    indata.open("packets.dat"); // opens the file
      while (indata)
      {
            for (int i=0; i<10; i++)
            {
                indata.get(codesTable[j][i]);
            }
 
            indata >> input2;
            j++;
      }
 
      for (int j=0; j<50; j++)
      {
          for (int i=0; i<10; i++)
          {
              cout << codesTable[j][i];
          }
          cout << "\n";
      }
      system("pause");
    return 0;
}
1101010101
1101101000
0101000110
...
is really
1101010101\n
1101101000\n
0101000110\n
...
where \n is the newline character. You have to clear the newline after each line before reading more data into codesTable.
Topic archived. No new replies allowed.