Ignoring the 1st Column in an Array?

How do I ignore the first column of data from a file? I need to read the three exam scores into an array; however, the first column contains the student ID. The next 3 columns contain exam scores. (Please do not use the standard library we have not learned it.)

Here is what the data file looks like. I need the bolded part of the data. (it is up to 250 rows, but I must assume there will be less than 300 students):
1
2
3
4
5
6
9074     62    78   73
9529     82    70   84
5635     82    63   66
9567     74    86   80
8162     82    90   70
5488     76    76   72


Here is my input fuction part of the code so far:
I am instructed to use structures for this program. Currently it is reading all of the data into the grades array which is not what I want to do.
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
grade input()
{
	grade one;
	ifstream file;
	file.open("History101.dat");

	if (!file.fail()) //test file is opened
	{
		cout << "File correctly opened" << endl;

		while (!file.eof())
		{
			for (int i = 0; i < ROW; i++)
			{
				for (int j = 0; j < COL; j++)
				{
					int temp;
					file >> temp;
					if (temp != '\n')
					{
						one.score[3] = temp;
						cout << one.score[3] << " ";
					}
				}
			}
		}
	}
	else
	{
		cout << "Error opening file!" << endl;
		file.close();
	}
	return one;
}
Last edited on
Just input the student id into a variable and don't do anything with it.
Can you give me psuedo code or an example?
Can anyone help me out? The code input is skipping for first line too. Also, for some reason it is printing 50 extra rows with "85". I am not sure why because I put:

 
if (temp != '\n')


Ex: http://i.imgur.com/DdpMnPI.png
Last edited on
closed account (SECMoG1T)
Only the first line, well add this on line ten, yanson had given you an idea.
 
string discard; getline (file, discard,'\n');// that's all you need , line 10 
Last edited on
That code removed the first row of data. To clarify, I am trying to only store the exam scores. In my first post the data file contains:

1
2
3
4
5
6
9074     62    78   73
9529     82    70   84
5635     82    63   66
9567     74    86   80
8162     82    90   70
5488     76    76   72


I wish to store 62, 78, 73 only.
Last edited on
closed account (SECMoG1T)
Okay I will suggest an alternative.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
struct exam
 {
   int score1;
   int score2;
   int score3;
 }

exam my_exam [300];
int discard, count=0; 

 ///after file is successfuly opened.

 while (file)
 {
   file>> discard; 
   file>>my_exam [count].score1>> my_exam [count].score2>> my_exam [count].score3;
   ++count; 
 }//can only work fine if atleast 300 students scores are present. 
Topic archived. No new replies allowed.