I took the liberty of making a few changes. Clearer names for variables and functions and got rid of some rubbish in terms of repeating game calls and descriptions . Feel free to use or not - mine works so you might find it useful for comparison :)
#include <iostream>
#include <stdlib.h>
#include <time.h>
#include <string>
usingnamespace std;
int setup_party_size()
{
int random_no_members = 0;
char dice_roll;
cout << "Welcome to Professor Scott and the Temple of Doom!\n";
cout << "Before you can enter you must roll a dice to see how many of your friends will follow you!\n\n";
cout << "Please [R]oll the dice to decide how many will dare enter with you.\n";
cin >> dice_roll;
if (dice_roll == 'R') {
srand(time(NULL));
random_no_members = rand() % 6 + 1;
cout << "You have been joined by " << random_no_members << " of your friends!\n\n";
}
else {
cout << "\nYou can't not roll!\n";
}
return random_no_members;
}
void fill_in_names(int no_members, string *member_list)
{
for (int i = 0; i < no_members; i++) {
cout << "Please enter a name for your party member: ";
cin >> member_list[i];
}
cout << "Your party consists of: ";
cout << endl;
for (int x = 0; x < no_members; x++) {
cout << member_list[x] << " " << x << "\n";
}
}
void game()
{
int no_members = setup_party_size();
string* member_name_list = new string[no_members];
fill_in_names(no_members, member_name_list);
cout << "Here's a repeat of the list of names:\n";
for (int y = 0; y < no_members; y++) {
cout << member_name_list[y] << "\n";
}
cout << "That's the end of the list\n";
}
int main()
{
char menu_choice;
cout << "Main Menu:\n";
cout << "[S]tart Game\n";
cout << "[E]xit Game\n\n";
cout << "Please choose an option: ";
cin >> menu_choice;
if (menu_choice == 'S') {
cout << "\nWelcome to The Temple of Doom!";
game();
}
elseif (menu_choice == 'E') {
cout << "\nMaybe you'll enter next time.";
} else {
cout << "\nPlease enter a valid option\n";
}
return 0;
}
Main Menu:
[S]tart Game
[E]xit Game
Please choose an option: S
Welcome to The Temple of Doom!Welcome to Professor Scott and the Temple of Doom!
Before you can enter you must roll a dice to see how many of your friends will follow you!
Please [R]oll the dice to decide how many will dare enter with you.
R
You have been joined by 4 of your friends!
Please enter a name for your party member: aa
Please enter a name for your party member: ss
Please enter a name for your party member: dd
Please enter a name for your party member: ff
Your party consists of:
aa 0
ss 1
dd 2
ff 3
Here's a repeat of the list of names:
aa
ss
dd
ff
That's the end of the list
Program ended with exit code: 0