2 dim array I/O files

So I am attempting to write a program to read from a file that is layed out like so:
Name
0.0 0.0 0.0 0.0 0.0
0.0
Name
0.0 0.0 0.0 0.0 0.0
0.0

and have it write to a file layed out like:
Name 0.0 0.0 0.0 0.0 0.0 0.0
Name 0.0 0.0 0.0 0.0 0.0 0.0

The only thing working in my program is the first getline(fin,name)
After that the output is just garbage.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
int length = 0;

	for (; length < ROW; length++)
	{

		getline(fin, name[length]);

		{
			for (int ctr = 0; ctr < COL; ctr++)
			{
				fin >> score[length][ctr];
				fin.ignore(80, '/n');
			}

			for (int ctrr = 0; ctrr < length; ctrr++)
			{
				fin >> difficulty[length];
				fin.ignore(80, '/n');
			}
		}

	}

	return length;


I am somewhat new to C++, and not exactly sure where to go from here.. I have the output function working, I believe my issue is with loading the arrays.

Just to note, there are 3 arrays I'm working with. 2 single dim arrays, and a 2dim array.

New to the forum as well.., any help would be appreciated.
Last edited on
You need a second getline() probably before the second loop.
Topic archived. No new replies allowed.