Tutorial by Examples

To generate true random values that can be used for cryptography std::random_device has to be used as generator. #include <iostream> #include <random> int main() { std::random_device crypto_random_generator; std::uniform_int_distribution<int> int_distribution(0,9); ...
A pseudo-random number generator generates values that can be guessed based on previously generated values. In other words: it is deterministic. Do not use a pseudo-random number generator in situations where a true random number is required. #include <iostream> #include <random> in...
The random number generator can (and should) be used for multiple distributions. #include <iostream> #include <random> int main() { std::default_random_engine pseudo_random_generator; std::uniform_int_distribution<int> int_distribution(0, 9); std::uniform_real_dis...

Page 1 of 1