I've seen some guide on generating random numbers with C: two things got me wondering:
- it is said that in addition to stdlib.h and time.h libraries I have to include the math.h library for it to work, why? (afaik the srand and rand functions are in stdlib)?
in the example the srand function is written the following way:
srand((unsingned int)time(NULL);
I'm using codeblocks and it works properly without the unsigned int and the math library, so why do they include it in the example?
thanks!
math.h
? It might give you some clues. Also, take a look at the type thattime()
returns, and whatsrand()
expects. – lorenzogtime_t
an integer or floating-point? – chux - Reinstate Monica