How to generate a random number in C? -
Is there a function to generate random numbers in C? Or do I have to use a third party library?
note : for security
rand ( ) Do not useif you need a cryptographically safe number, instead.
#include & lt; Time.h> # Include & lt; Stdlib.h & gt; Srand (time (zero)); // should only be called int r = rand (); Pseudo random integer between // 0 and RAND_MAX
Comments
Post a Comment