Roger 210
Mike 150
Wayne 500
Conner 240
Ford 456
Fire 160
Robert 320
Andrew 480
The above is my text file (ignore the extra lines between the words) and I would like to read the .txt file into a cpp file into one int array and one string array. How would I do this?
The arrays are int[vote] and string[name].
Currently I have this:
string name[ASIZE]; int vote[ASIZE];
string s;
ifstream infile("input.txt");
for (int i=0; i<ASIZE; i++)
{
infile >> vote[i];
infile.ignore();
getline(infile, name[i]);
infile >> name[i] >> vote[i];
}
Please help!! I am a beginner and having trouble understanding arrays and we are required to use two different ones.