The code I have for the rolling of the dice is in a function:
void Dice(int &dice1, int &dice2)
{
dice1 = rand() % 6 + 1;
dice2 = rand() % 6 + 1;
}
but when it is in main
int main()
{
srand(time(NULL));
int dice1;
int dice2;
Dice(dice1, dice2);
cout << "Player 1's Roll: " << dice1 << " and " << dice2 << endl;
cout << "Player 2's Roll: " << dice1 << " and " << dice2 << endl;
}
and when I run the program, the output is that player 2's rolls are always the same as player 1's.
Example:
Player 1's Roll: 1 and 4
Player 2's Roll: 1 and 4
How do I fix this (without having to have another function) so that Player 2 may have difference dice rolls?