Skip to content

Latest commit

 

History

History
50 lines (35 loc) · 1.93 KB

File metadata and controls

50 lines (35 loc) · 1.93 KB
description title ms.date api_name api_location api_type topic_type f1_keywords helpviewer_keywords
Learn more about: srand
srand
4/2/2020
srand
_o_srand
msvcrt.dll
msvcr80.dll
msvcr90.dll
msvcr100.dll
msvcr100_clr0400.dll
msvcr110.dll
msvcr110_clr0400.dll
msvcr120.dll
msvcr120_clr0400.dll
ucrtbase.dll
api-ms-win-crt-utility-l1-1-0.dll
ntoskrnl.exe
DLLExport
apiref
STDLIB/srand
srand
random starting point
random starting point, setting
random numbers, generating
srand function
numbers, pseudorandom
numbers, random
pseudorandom numbers
starting points, setting random
starting points

srand

Sets the starting seed value for the pseudorandom number generator used by the rand function.

Syntax

void srand(
   unsigned int seed
);

Parameters

seed
Seed for pseudorandom number generation

Remarks

The srand function sets the starting point for generating a series of pseudorandom integers in the current thread. To reinitialize the generator to create the same sequence of results, call the srand function and use the same seed argument again. Any other value for seed sets the generator to a different starting point in the pseudorandom sequence. rand retrieves the pseudorandom numbers that are generated. Calling rand before any call to srand generates the same sequence as calling srand with seed passed as 1.

By default, this function's global state is scoped to the application. To change this behavior, see Global state in the CRT.

Requirements

Routine Required header
srand <stdlib.h>

For more compatibility information, see Compatibility.

Example

See the example for rand.

See also

Math and floating-point support
rand