I'm attempting to develop a dice game, and I need random numbers to represent the sides of the die.
I can make a number between 1 and 6).
Using
#include <cstdlib>
#include <ctime>
#include <iostream>
using namespace std;
int main()
{
srand((unsigned)time(0));
int i;
i = (rand()%6)+1;
cout << i << "\n";
}
doesn't function very well since when I run the programme a few times, I receive the following output:
6
1
1
1
1
1
2
2
2
2
5
2
So I'd need a command that generates a distinct random number each time, rather than the same one five times in a row.
Is this something that can be done with a command?