This is my first time using pointers and I'm having some trouble. So far I have declared a struct named Student which is meant to hold the data for each student. There is an input file with an unknown amount of entries. Each entry has a first and last name along with 7 scores.
I am trying to read in the data from the text file at this point. Then I will need to sort the data (selection sort) in alphabetical order by the students last names. And lastly output the data to a new text file.
Below I'll provide what I've done so far. Really I'm just trying to get a better insight as to how I should be approaching this problem. I can figure out the sorting and output later.
A sample entry from the input file:
ANTHONY CLARK 83 85 84 85 82 85 78
#include <fstream>
#include <iostream>
using namespace std;
struct Student
{
char First[30];
char Last[30];
float Score1, Score2, Score3, Score4, Score5, Score6, Score7;
};
int main()
{
ifstream infile;
ofstream outfile;
int size=5;
infile.open("input.txt");
struct Student * data;
data = new struct Student[size];
for (int i = 0; i < size; i++ )
{
infile.getline(data[i].First,30);
}
infile.close();
outfile.open("output.txt");
outfile.close();
delete [] data;
return 0;
}