You have a number of problems.
Line 12,18: You have two arrays named golferNames. One global. One in main. Which one did you want to use? Generally globals should be avoided.
Line 22: cin >> stops at the first space. As jonnin pointed out in your other thread, if the user enters first name and last name, you will get only the first name. Use
|
getline (cin,golferName[x].
|
Line 22: You also have a empty getNames() function, but you're getting the names here.
Nowhere do you ask for the scores. Be careful mixing cin >> and getline(). cin >> stops at the first whitespace. getline() stops at '\n'.
Line 29: You sort only sorts integers. When you do a swap, you need to swap both the golferName and the score.
Line 29: You have no check for a sentinel.
Lines 36-46: C++ provides a sort() function.
Lines 48-53: C:: provides a swap() function. Of course, if you use the built-in sort() function, you don't need your own swap() function.
Have you learned structs? You should really place name and score in a struct.
1 2 3 4 5
|
struct golfers_t
{
string name;
int score;
} golfers[24];
|
PLEASE ALWAYS USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.