This function of stdlib will initialize the random number generator that can be used with the rand() function.
Usage of srand():
void srand ( unsigned int seed ); Precision tune auto care mn.
Apr 28, 2015 srand function is used to change the seed of the random number generator. By setting srand(time(NULL)), you are setting the seed of the random number generator to the current time. By doing this every time you run the program you will get different random sequences: - For example, for the first run if you are getting 2,78,45,60. Seeds the pseudo-random number generator used by rand with the value seed. If rand is used before any calls to srand, rand behaves as if it was seeded with srand(1). Each time rand is seeded with the same seed, it must produce the same sequence of values. Srand is not guaranteed to be thread-safe. Apr 28, 2015 A random number generator requires a number (it is called seed) to generate random numbers. If the random number generator is given the same seed then every time it will generate the same sequence of random numbers. การเขียนโปรแกรมสุ่มเลข หรือrandom ในภาษา c, c จะใช้ 2 function หลักๆคือ. C library function - srand - The C library function void srand(unsigned int seed) seeds the random number generator used by the function rand.
C++ Using Srand
The function srand() is used to initialize the pseudo-random number generator by passing the argument seed.
Often the function time is used as input for the seed.
If the seed is set to 1 then the generator is reinitialized to its initial value. Then it will produce the results as before any call to rand and srand.
Srand Function In Dev C Download
An integer value to initialize the random number generator. Often the function time is used as input for the seed.
There is nothing returned by srand.