I need to create an array of struct with the struct being a student (with data types string FirstName, string LastName, int testScore, and char Grade). I have the logic figured out for the function prototypes, and I have learned a little bit of basic file i/o. I want 20 students in the array of structs, and the info is to be read in from .txt files. This is where I am having trouble. Here is my basic code.
#include "stdafx.h"
#include <iostream>
#include <fstream>
using namespace std;
struct studentType {
string firstName;
string lastName;
int testScore;
char Grade;
};
int main()
{
studentType students[20];
int i;
ifstream inputFile;
inputFile.open("testScores.txt");
for (i = 0; i < 20; i++)
inputFile >> students->testScore;
cout << "The test scores entered are: ";
for (i = 0; i < 20; i++)
cout << " " << students->testScore;
return 0;
}
[]