racing_game/random.cpp

18 lines
335 B
C++
Raw Normal View History

2019-05-25 14:24:49 +10:00
#include <fstream>
unsigned long long random_get_seed()
{
// Open the random device
std::ifstream rand_dev("/dev/urandom");
// Read some random bytes to get the seed
unsigned long long seed;
rand_dev.read((char*)&seed, sizeof(seed));
// Close the random device
rand_dev.close();
// Return the seed
return seed;
}