Click here to Skip to main content
15,881,803 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I'm a beginner of C (and coding in general), trying to generate easy random numbers in visual studio.

However it seems that due to my system being 64bit, srand(time(NULL)) do not work.

After some searching, I tried srand((unsigned int)time(NULL)) too but the compiler still gave an error message (about srand returning void value).

Is there anyway to bypass this problem?
Posted
Updated 2-Oct-19 2:42am

1 solution

std::srand only initialises the random number generator to a specific point along the pseudo-random sequence. It doesn't return anything. You need to call std::rand to actually get a number.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900