I have made a simple application to demostrate the problem I got in making a much more complicated one (didn't want to post all of it here). I don't know how to add character values longer than one letter to arrays.
#include <iostream>
using namespace std;
int main()
{
char name;
int score;
int scores[11] = {1,2,3,4,5,6,7,8,9,10};
char names[11][11] =
{"None", "None", "None", "None", "None", "None", "None", "None", "None", "None"};
int next;
loopmenu:
cout << "Type 1 to add new record, 2 to see high scores and 3 to exit.";
cin >> next;
switch(next)
{
case 1:
goto loopcontinue;
break;
case 2:
goto loophighscores;
break;
case 3:
return 0;
}
loopcontinue:
cout << "Type name:";
cin >> name;
cout << "Type score:";
cin >> score;
if(score > scores[9])
{
cout << "New best score!";
names[9][1] = name; // Here's the problem! What should I write here?
}
// Same code x9....
loophighscores:
cout << "Highscores: \n";
for(int a = 0; a < 10; a++)
{cout << a + 1 << ". " << scores[a] << " points by " << names[a] << "\n";};
goto loopmenu;
std::cin.get();
return 0;
}
Thank you!
EDIT: And could someone please tell me any possible alternatives to using goto, as I know that everyone hates it.