Option 2 isn’t difficult, here you go:
srand(time(NULL));
you’ll need to include stdlib.h
for srand()
and time.h
for time()
.
More Related Contents:
- Why do people say there is modulo bias when using a random number generator?
- How to generate a random number in C++?
- Generate random numbers using C++11 random library
- Why does rand() yield the same sequence of numbers on every run?
- How to generate different random numbers in a loop in C++?
- Create Random Number Sequence with No Repeats
- Random number generation in C++11: how to generate, how does it work? [closed]
- How to succinctly, portably, and thoroughly seed the mt19937 PRNG?
- Generate random numbers following a normal distribution in C/C++
- Rand() % 14 only generates the values 6 or 13
- Same random numbers every loop iteration
- Random array generation with no duplicates
- How does modulus and rand() work?
- Random number c++ in some range [duplicate]
- What is the optimal algorithm for generating an unbiased random integer within a range?
- If we seed c++11 mt19937 as the same on different machines, will we get the same sequence of random numbers
- How do I generate thread-safe uniform random numbers?
- Consistent pseudo-random numbers across platforms
- Getting big random numbers in C/C++
- srand(time(NULL)) generating similar results [duplicate]
- Generating a random integer from a range
- Is 1.0 a valid output from std::generate_canonical?
- Same random numbers every time I run the program
- The implementation of random_device in VS2010?
- Why Aren’t `std::uniform_int_distribution` and `std::uniform_int_distribution` Allowed?
- How to make sure that std::random_shuffle always produces a different result?
- C++11 cross compiler/standard library random distribution reproducibility
- How does calling srand more than once affect the quality of randomness?
- Generate N random numbers within a range with a constant sum
- What difference between rand() and random() functions?