memshuffle man page on DragonFly

Man page or keyword search:  
man Server   44335 pages
apropos Keyword Search (all sections)
Output format
DragonFly logo
[printable version]

MEMSHUFFLE(3)		     C Programmer's Manual		 MEMSHUFFLE(3)

NAME
       memshuffle - make an array be in random order

SYNOPSIS
       #include <publib.h>
       void *memshuffle(void *block, size_t elsize, size_t elnum);

DESCRIPTION
       memshuffle  will move around the elements of an array in a random fash‐
       ion.  It uses the standard library function rand(3) to get the  pseudo-
       random  numbers	it  needs.   The  caller must set a suitable seed with
       srand(3).

RETURN VALUE
       memshuffle returns its first argument.

EXAMPLE
       To shuffle an integer array one might do the following.

	    int array[4] = { 1, 2, 3, 4 };

	    memshuffle(array, sizeof(array[0]), 4);

BUGS
       On many systems rand(3) is not of very good quality.   However,	it  is
       the  only random number generator that can be assumed to exist.	Making
       it possible for the caller to provide an	 alternate  source  of	random
       numbers (e.g., via a function pointer) is perhaps too more trouble than
       its worth.  A better way would be for everyone to fix their rand's.

SEE ALSO
       publib(3), memrev(3), rand(3), srand(3)

AUTHOR
       Lars Wirzenius (lars.wirzenius@helsinki.fi)

Publib			     C Programmer's Manual		 MEMSHUFFLE(3)
[top]

List of man pages available for DragonFly

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net