ok in this program i am making you can change the number of players that can play in the game. I would like to make it so that what ever the number of players you pick would change the size of the array that stores the names of the players.
heres some code:
Code:
int main()
{
int num_players = 2;
char player_names[5][15] = {" "}; // this holds the players names
char player1[15];
char player2[15];
char player3[15];
char player4[15];
char player5[15];
Heres The Player Selection Part:
Code:
cout << "Number Of Players: ";
cin >> num_players;
if (num_players == 2)
{
system("Cls");
cout << "Enter Player Names (15 Char. Max!)" << endl;
cout << "Player 1: ";
cin >> player1;
cout << "Player 2: ";
cin >> player2;
}
else if (num_players == 3)
{
system("Cls");
cout << "Enter Player Names (15 Char. Max!)" << endl;
cout << "Player 1: ";
cin >> player1;
cout << "Player 2: ";
cin >> player2;
cout << "Player 3: ";
cin >> player3;
}
else if (num_players == 4)
{
system("Cls");
cout << "Enter Player Names (15 Char. Max!)" << endl;
cout << "Player 1: ";
cin >> player1;
cout << "Player 2: ";
cin >> player2;
cout << "Player 3: ";
cin >> player3;
cout << "Player 4: ";
cin >> player4;
}
else if (num_players == 5)
{
system("Cls");
cout << "Enter Player Names (15 Char. Max!)" << endl;
cout << "Player 1: ";
cin >> player1;
cout << "Player 2: ";
cin >> player2;
cout << "Player 3: ";
cin >> player3;
cout << "Player 4: ";
cin >> player4;
cout << "Player 5: ";
cin >> player5;
thanks for the help.