srand(time(NULL)); in MSDN 2010
-
I got the following compile error message, for using: srand(time(NULL)); warning C4244: 'argument' : conversion from 'time_t' to 'unsigned int', possible loss of data Thanks
It's not an error, but a warning. Try:
srand((unsigned) time(NULL));
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
-
I got the following compile error message, for using: srand(time(NULL)); warning C4244: 'argument' : conversion from 'time_t' to 'unsigned int', possible loss of data Thanks
As already stated, it's not an error but a warning. Compiler is simply making sure you're doing it on purpose and not by mistake, remember that casting may lead to digits being dropped and rounding (hence the warning). Cast the data to the appropriate type and the compiler won't warn you about it anymore.