int generateRandomNumber(int n)
{
srand(time(NULL));
return rand() % n;
}
This is equivalent to applying a hash function to the clock with a resolution of one second.
It means that rand() isn't following a pseudo-random number sequence, and that if you call it N times within the same second you'll get the same answer N times.
Use srand() once, initially in main, to select a pseudo-random number sequence to iterate using rand.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
This is equivalent to applying a hash function to the clock with a resolution of one second.
It means that rand() isn't following a pseudo-random number sequence, and that if you call it N times within the same second you'll get the same answer N times.
Use srand() once, initially in main, to select a pseudo-random number sequence to iterate using rand.