I'm currently reading a beginner book on C++ and it has this example:
int main()
{
srand(static_cast<unsigned int>(time(0))); //seed random number generator
int randomNumber = rand(); //generate random number
int die = (randomNumber % 6) + 1; // get a number between 1 and 6
cout << "You rolled a " << die << endl;
return 0;
}
I just want to know the purpose of the cast. I tried
cout << time(0);
and
cout << static_cast<unsigned int>(time(0));
it produces the same result so I'm not sure why the cast in the code.