mirror of https://github.com/mkerrisk/man-pages
strfry.3: Remove incorrect reference to rand(3)
The strfry(3) function does not use rand(). The original version from 1995 did, but it was changed to use a different PRNG in glibc commit 4770745624b7f7f25623f1f10d46a4c4d6aec25c, 1996-12-04. This C program demonstrates the behavior. By not calling srand(), it gets the same values for successive calls to rand(), but strfry() returns a different value each time the program is run. If strfry() called srand(), it would alter the sequence of numbers return by rand(). int main(void) { printf("%d\n", rand()); char alphabet[] = "abcdefghijklmnopqrstuvwxyz"; puts(strfry(alphabet)); printf("%d\n", rand()); } Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
parent
a13b92e5da
commit
3244025362
|
@ -42,10 +42,7 @@ The
|
|||
.BR strfry ()
|
||||
function randomizes the contents of
|
||||
.I string
|
||||
by
|
||||
using
|
||||
.BR rand (3)
|
||||
to randomly swap characters in the string.
|
||||
by randomly swapping characters in the string.
|
||||
The result is an anagram of
|
||||
.IR string .
|
||||
.SH RETURN VALUE
|
||||
|
|
Loading…
Reference in New Issue