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:
Keith Thompson 2018-11-09 04:55:55 +01:00 committed by Michael Kerrisk
parent a13b92e5da
commit 3244025362
1 changed files with 1 additions and 4 deletions

View File

@ -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