need help understanding line by line + struct

Hello

For my last lab for the course, we need to do the following:
1) read a file
this file has 5 lines, each line has 3 componenets : first name , last name , and grade given as integer.

2)we need to use Struct to read the information and store it.

3) we need to output the data with cout.

4) We need to give the student's Fname,Lname and grade with highest score and lowest score.

note : if two students share a grade, its irrelevent which one is outputed at end.


Now....


I am having problem inputing the data ,

How can i write a loop that alternate between Fname,Lname, and grade after switching to next line?

this is my program so far :

#include <iostream>
#include <fstream>
#include <string>
using namespace std;


struct students
{

string first ;
string last;
int score;
char grade ;

};

const int max = 5 ;

int main ()
{

students student[max];
int counter = 0 ;

fstream file ;
file.open (" lab6.txt" ) ;




THANKS!!
What error are you getting? Is the text file in the same directory as the compiled program?
Topic archived. No new replies allowed.