From 82ba818ff456bcd6d56a06226e3f27e98fbb55c3 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Thu, 14 Aug 2025 22:58:58 -0500 Subject: removing all downloaded devdocs files --- devdocs/c/numeric%2Frandom%2Fsrand.html | 38 --------------------------------- 1 file changed, 38 deletions(-) delete mode 100644 devdocs/c/numeric%2Frandom%2Fsrand.html (limited to 'devdocs/c/numeric%2Frandom%2Fsrand.html') diff --git a/devdocs/c/numeric%2Frandom%2Fsrand.html b/devdocs/c/numeric%2Frandom%2Fsrand.html deleted file mode 100644 index b51663b0..00000000 --- a/devdocs/c/numeric%2Frandom%2Fsrand.html +++ /dev/null @@ -1,38 +0,0 @@ -

srand

Defined in header <stdlib.h>
void srand( unsigned seed );
-

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.

-

Parameters

- -
seed - the seed value

Return value

(none)

-

Notes

Generally speaking, the pseudo-random number generator should only be seeded once, before any calls to rand(), and the start of the program. It should not be repeatedly seeded, or reseeded every time you wish to generate a new batch of pseudo-random numbers.

-

Standard practice is to use the result of a call to time(0) as the seed. However, time() returns a time_t value, and time_t is not guaranteed to be an integral type. In practice, though, every major implementation defines time_t to be an integral type, and this is also what POSIX requires.

-

Example

#include <stdio.h>
-#include <stdlib.h>
-#include <time.h>
- 
-int main(void)
-{
-    srand(time(NULL)); //use current time as seed for random generator
-    int random_variable = rand();
-    printf("Random value on [0,%d]: %d\n", RAND_MAX, random_variable);
-}

Possible output:

-
Random value on [0 2147483647]: 1373858591

References

See also

- - -
generates a pseudo-random number
(function)
maximum possible value generated by rand()
(macro constant)
C++ documentation for srand
-

- © cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
- https://en.cppreference.com/w/c/numeric/random/srand -

-
-- cgit v1.2.3