GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||
GeezerVison is showing cplusplus.com — srand Reference
<cstdlib> (stdlib.h)
function
<cstdlib>
srandvoid srand (unsigned int seed); Initialize random number generator
For every different seed value used in a call to srand, the pseudo-random number generator can be expected to generate a different succession of results in the subsequent calls to rand. Two different initializations with the same seed will generate the same succession of results in subsequent calls to rand. If seed is set to 1, the generator is reinitialized to its initial value and produces the same values as before any call to rand or srand.In order to generate random-like numbers, srand is usually initialized to some distinctive runtime value, like the value returned by function time (declared in header <ctime>). This is distinctive enough for most trivial randomization needs. Parameters
Return ValuenoneExample
Possible output:
Data racesThe function accesses and modifies internal state objects, which may cause data races with concurrent calls to rand or srand.Some libraries provide an alternative function of rand that explicitly avoids this kind of data race: rand_r (non-portable). C++ library implementations are allowed to guarantee no data races for calling this function. Exceptions (C++)No-throw guarantee: this function never throws exceptions.See also
Home page | Privacy policy
© cplusplus.com, 2000-2026 - All rights reserved - v3.3.4s Spotted an error? contact us | |||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |