#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
usingnamespace std;
constint MAX_STUDENTS = 80; //Max Number of students
constint col = 12; //Number of students
void readData(string studentName[], int friendList[][col], int &studentSize); //Read data from inputfile
int main()
{
int studentSize; //Use this to read first number of inputfile
string studentName[MAX_STUDENTS]; //String array for student's name
int friendList[MAX_STUDENTS][col]; //2D array for the set of numbers
readData(studentName, friendList, studentSize);
cout << studentSize; //Test to see if input file is correct
return 0;
}
void readData(int studentName[], int friendList[][col], int &studentSize)
{
ifstream inputFile;
inputFile.open("3club.txt");
if(inputFile.fail())
{
cout<< "Input file was unable to open." <<endl;
}
inputFile >> studentSize;
for(int current = 0; current < studentSize; current++)
{
inputFile >> studentName[current];
}
for(int row = 0; row < studentSize; row++)
{
for(int col = 0; col < studentSize; col++)
{
inputFile >> friendList[row][col];
}
} //End for-loop
}
I just need help trying to read the data from the specific text file that is listed above the code. The input file "3club.txt" is the input file above the code. I am suppose to read the the studentSize which would be 12 in the first line of the text file. The names are listed into studentName[] and the matrix is stored inside of friendList[].