Hızlı yanıt: kod örneği
If you call without first calling , the behavior is as if you called with as the argument.This behavior is defined in the original C standard. I don't have a full copy of it handy, but The Open Group's POSIX standards are the next best thing, as they incorporate the full C standard (with some extensions):http://www.opengroup.org/onlinepubs/000095399/functions/rand.htmlThe srand() function uses the argument as a seed for a new sequence of pseudo-random numbers to be returned by subsequent calls to rand(). If srand() is then called with the same seed value, the sequence of pseudo-random numbers shall be repeated. If rand() is called before any calls to srand() are made, the same sequence shall be generated as when srand() is first called with a seed value of 1.The actual result of a call for any given seed is implementation-defined, except that for any seed x, call n to after the seeding of the generator must return the same result. So while on your implementation you will always get 41 on the first call after calling , and you will always get the same result (whatever it is) for the second call, other implementations may use a different algorithm that produces different results.
rand()
srand()
srand()
1
rand()
rand()
rand()
srand(1)
rand()