What kind of approach is the best at generating a random 2-digit number (using only the standard C++ library)? These 2 seem like the most obvious, but I want to know which one is better and if there is a better one.
//1
#include <iostream>
#include <cstdlib>
#include <ctime>
int main()
{
std::srand(std::time(NULL));
std::cout << "Random value: " << std::rand() % 100;
return 0;
}
//2
#include <iostream>
#include <random>
int main()
{
std::random_device rnd;
std::cout << "Random value: " << rnd() % 100;
return 0;
}