RAND(3) BSD Library Functions Manual RAND(3)NAME
rand, rand_r, srand, sranddev -- bad random number generator
LIBRARY
Standard C Library (libc, -lc)
SYNOPSIS
#include <stdlib.h>
int
rand(void);
int
rand_r(unsigned *seed);
void
srand(unsigned seed);
void
sranddev(void);
DESCRIPTION
These interfaces are obsoleted by arc4random(3).
The rand() function computes a sequence of pseudo-random integers in the range of 0 to RAND_MAX (as defined by the header file <stdlib.h>).
The srand() function sets its argument seed as the seed for a new sequence of pseudo-random numbers to be returned by rand(). These
sequences are repeatable by calling srand() with the same seed value.
If no seed value is provided, the functions are automatically seeded with a value of 1.
The sranddev() function initializes a seed, using the random(4) random number device which returns good random numbers. However, the rand()
function still remains unsuitable for cryptographic use.
The rand_r() function provides the same functionality as rand(). A pointer to the context value seed must be supplied by the caller.
SEE ALSO arc4random(3), random(3), random(4)STANDARDS
The rand() and srand() functions conform to ISO/IEC 9899:1990 (``ISO C90'').
The rand_r() function is as proposed in the POSIX.4a Draft #6 document.
BSD May 25, 1999 BSD
Check Out this Related Man Page
RAND(3) BSD Library Functions Manual RAND(3)NAME
rand, rand_r, srand, sranddev -- bad random number generator
LIBRARY
Standard C Library (libc, -lc)
SYNOPSIS
#include <stdlib.h>
int
rand(void);
int
rand_r(unsigned *seed);
void
srand(unsigned seed);
void
sranddev(void);
DESCRIPTION
These interfaces are obsoleted by arc4random(3).
The rand() function computes a sequence of pseudo-random integers in the range of 0 to RAND_MAX (as defined by the header file <stdlib.h>).
The srand() function sets its argument seed as the seed for a new sequence of pseudo-random numbers to be returned by rand(). These
sequences are repeatable by calling srand() with the same seed value.
If no seed value is provided, the functions are automatically seeded with a value of 1.
The sranddev() function initializes a seed, using the random(4) random number device which returns good random numbers. However, the rand()
function still remains unsuitable for cryptographic use.
The rand_r() function provides the same functionality as rand(). A pointer to the context value seed must be supplied by the caller.
SEE ALSO arc4random(3), random(3), random(4)STANDARDS
The rand() and srand() functions conform to ISO/IEC 9899:1990 (``ISO C90'').
The rand_r() function is as proposed in the POSIX.4a Draft #6 document.
BSD May 25, 1999 BSD
Hi all,
Is the rand() function in C uniform or normal distribution. If it is unform, is there a random function that is normal.
Thanks and Regards (2 Replies)
can any one tell me how to create integer random no between 10 to 40 in C language.When i m using random() or rand() functions they r creting some
long int which is not required (5 Replies)
Hi,
I am currently trying to generate multiple random numbers in C for different variable:-
die1=1+(rand()%5);
die2=1+(rand()%5);
die3=1+(rand()%5);
die4=1+(rand()%5);
But I need to contrain the total of die1, die2,die3 and die4 to be 5 as well. If i insert die1+die2+die3+die4=5, i do... (6 Replies)
Can anyone tell me what could be the solution to following :
I have one .txt file which contains some seed information. This seed may appear multiple time in the file so what I want do is if this seed appears again in the file then that line should be removed.
here is the contents of .txt... (5 Replies)
Can anyone tell me what could be the solution to following :
I have one .txt file which contains some "seed" information. This seed may appear multiple time in the file so what I want do is if this seed appears again in the file then that line should be removed.
Please provide the script code... (4 Replies)
Hi
I'm trying to generate random numbers both in parent process and the child process. But I get the same random number in both processes. Why doesn't it generate different numbers altough I seed random number generator?
Here's my code:
#include <stdio.h>
#include <unistd.h>
#include... (2 Replies)
Hi, I need a script that parses and greps data out of a textfile.
I have a text file that has this structure:
File1
host1.localdomain
text random text
Found errors
this text is random (41123) --- random random
at.5165 ---- random random
at.5165 ---- random random
at.5165 ----... (2 Replies)
Hi,
Do anybody knows how to use awk or any command to random print out 1000 number which start from range 1 to 150000?
I know that "rand" in awk can do similar random selection.
But I have no idea how to write a code that can random pick 1000 number from range 1 to 150000 :confused:
... (1 Reply)