Despite trying to follow the conventions for a void function, I still have an issue with the bug at line 17 that is going to keep me from finishing this assignment, the objective of which is to make a program to print out high scores and associated names from two different arrays. My problem is simply with the void function needed to input scores and names. Thanks! Also, the compiler in Xcode wants another '}' at end of input (at return 0;). Another } for what, I do know.
a) why do you have two using namespace stds?
b) why do you have them in main?
c) you cant have functions within functions in c++. you would have to do this:
#include <iostream>
#include <string>
using std::cout;
using std::endl;
using std::cin;
using std::string;
void initializeArrays(string Names[], int Scores[], constint size);
void DisplayTops(string Names[], int Scores[]);
int main()
{
constint size = 5;
string Names[size];
int Scores[size];
initializeArrays(Names, Scores, Size);
return 0;
}
void initializeArrays(string Names[], int Scores[], constint size)
{
for (int i = 0; i < size; i++)
{
cout << "Enter the name for score #" << i << ";" << endl;
cin >> Names[i];
cout << "Enter the score for Name #" << i << ";" << endl;
cin >> Scores[i];
}
}
d) as for the error you were getting, because you were trying to declare a function within a function, your compiler saw it as a normal function call that was missing a semicolon (well it couldnt actually tell it was that but thats not important)