Share this page

# srand

Mathematics Functions

Seeds the pseudo-random number generator.

    int srand( seedTime );

Before invoking rand, call srand to seed the pseudo-random number generator.

## Return Value

Returns a pseudo-random integer in the range 0 to 32767.

## Example

The following example generates 2 random numbers, each kept within a specific range using the mod (%) operator.

     // Srand is called before rand

        srand(time(NULL));

    // Generate some random numbers

        lr_output_message ("A number between 0 and 100: %d\n", rand() % 100);
        lr_output_message ("A number between 20 and 30: %d\n", rand() % 10+20);

    Example: Output:
    Action.c(7): A number between 0 and 100: 72
    Action.c(8): A number between 20 and 30: 28

Tips to improve your search results... VuGen Function Reference Version 26.1 Function Reference 26.1 All View Local Help Center View Online Help Center Version: