Hi @g8whitebuffalo,
There are multiple ways I would do what you requested, and here are some:
Use files. Basically, whenever you introduce a name, you access either:
1. a file with the golfer's name, or
2. a file which contains multiple golfers and their stats.
I would highly recommend using files, and so I will help you with it:
For 2. you might want to also use objects. If you don't want to or don't know them, then it's not a problem.
But at least using structures is pretty much necessary.
Here's a sample:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
struct golferData
{
//some data
};
int main()
{
//create a list of golferData structures, or an array if you want to keep it simple (which is not
//so good)
fstream file;
string fileName, golferName;
int score;
fileName="Golfers List.txt";
file.open(fileName.c_str(), ios::in);
while (getline(file, golferName))
{
file>>score;
golferPlayer->pointsPerSeason=score;
golferPlayer->playerName=golferName;
}
}
|
Note that this is a point of reference.
Anyway, for 1. it's kinda better if you want to access it directly, but it takes some more writing:
1 2 3 4 5 6 7 8 9 10 11
|
int functionCreateFile(string fileName)
{
fstream checkFile;
checkFile.open(fileName.c_str(), ios::in);
if (checkFile.is_open())
{
return 0;
}
fstream newFile;
newFile.open(fileName.c_str(), ios::out);
}
|
For this you might want to consider adding an extension to the file, if it's needed.
Also it's for the best to first modify the file name, so that if you input "PlaYEr SomeONE STEVe", then it firstly is transformed to "Player Someone Steve".
This is for storing data.
And using the same mechanism for the user will help in reading the file with the name directly.
Now if it's not for using files, you must write everything in the source code.
That is not pleasant for the programmer, and if there's one misspelling, then you must recompile and many problems can emerge.
Hope this helps.