Estoy buscando generar valores aleatorios enteros grandes, no negativos en un sistema POSIX. He encontrado 2 posibles funciones que se ajustan a la factura, y sus respectivos inicializadores:Números aleatorios en la API POSIX C
#include <stdlib.h>
long int random(void);
void srandom(unsigned int seed);
CONFORMING TO
4.3BSD, POSIX.1-2001.
// and
long int lrand48(void);
void srand48(long int seedval);
CONFORMING TO
SVr4, POSIX.1-2001.
- Qué funciones se prefieren (rosca a la seguridad y la gama de valores generada)?
- Teniendo en cuenta que la seguridad no es una preocupación, ¿cómo debo sembrarlos?
- ¿Deben diferir los métodos de siembra debido a los diferentes argumentos para las funciones de inicialización (
long int
vs.unsigned int
)?
si tiene un sistema POSIX puede también use '/ dev/urandom' o'/dev/random' –