Thanks that worked but only so much. I do not know functions all that well yet because I am used to doing everything in main(). I think i need to change the function type to void or change something on what the function returns or its just not reading data into the array right. Does it matter where functions are placed in a .cpp file anyway?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
int contestantInfo(int contestantNumber, string& contestantName)
{
string list[ARRAY_SIZE];
std::ifstream inFile("contestantname.data");
while(inFile >> contestantNumber && std::getline(inFile, contestantName))
{
list[contestantNumber - 1] = contestantName;
}
cout << contestantNumber << " " << contestantName << endl;
return contestantNumber;
}
|
Note: ARRAY_SIZE is a constant of 20.
The output of this after it is called just displays a zero and goes back to the menu to reselect which option to choose from main().
Which option would you like?:
1 - Display all data for a contestant
2 - Display total catch weight for fish type
3 - Display biggest fish caught for fish type
4 - Quit
Choice is: 1
What contestant would you like to see?: 11
0
Which option would you like?:
1 - Display all data for a contestant
2 - Display total catch weight for fish type
3 - Display biggest fish caught for fish type
4 - Quit
Choice is: 4
bash-2.04$
In contestantname.data contestant 11 is not in the 11th spot but that should not matter and the name is my name.
Thanks in advance for the help.