totn C Functions

C Language: srand function
(Seed Pseudo-Random Number Generator)

In the C Programming Language, the srand function initializes the sequence of pseudo-random numbers generated when the rand function is called.

Syntax

The syntax for the srand function in the C Language is:

void srand(unsigned int seed);

Parameters or Arguments

seed
The seed value for the rand function. The seed value determines a particular sequence of random numbers when calling the rand function. If a program always uses the same seed value, the rand function will always get the same sequence of numbers.

Returns

The srand functiondoes not return anything.

Required Header

In the C Language, the required header for the srand function is:

#include <stdlib.h>

Applies To

In the C Language, the srand function can be used in the following versions:

  • ANSI/ISO 9899-1990

Similar Functions

Other C functions that are similar to the srand function: