Populating Arrays with info from .txt file using a fuction

So I am given three .txt files, one with names, and the other two with before and after weights (integers) and I am supposed to create 3 arrays (each of size 10) to hold the information from these files.
In addition, I must also write a function to populate these arrays.
I am not sure exactly how to do this; specifically, I do not know how to transfer the information from the .txt files into the arrays using the void function.

This is what I have so far (I am new to programming, so I apologize in advance if this looks completely off):

void PopulateArrays(string name);
void PrintResults();

int main()
{
string namearray[10];
int beforearray[10];
int afterarray[10];

string name;

ifstream infile;
ifstream infile2;
ifstream infile3;

infile.open("Names.txt");
infile2.open("Before.txt");
infile3.open("After.txt");


while(!infile.eof())
{
getline(infile, namearray[10]);
PopulateArrays(namearray[10]);

}


infile.close();
infile2.close();
infile3.close();



return 0;
}

void PopulateArrays(string name)
{
for(int i = 0; i < 10; i++)
{
cout<<name[i]<<endl;
}



}

Any help would be greatly appreciated! Thank you!
Last edited on
Topic archived. No new replies allowed.