My main question is how to solve where I am going wrong with my code, I am a moderately skilled programmer and I was assigned this code for one of my projects. The problem starts in the getData function after reading through the if statement.
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
struct Person
{
float avg;
string name;
int age;
};
void GetData(ifstream& infile, string name[], int age[], float ave[])
{
if (infile.is_open())
{
int i = 0;
infile >> name[5] >> age[5];
for (int j = 0; j < 5; j++)
infile >> ave[i];
i++;
}
else
cout << "The file could not be opened" << endl;