Running a rand or random script

Simon Barner barner at in.tum.de
Mon Jun 16 09:51:29 PDT 2003


Whoops, did too much C++ programming these days, in C this should really
be:

#include <stdlib.h>
#include <time.h>
 
int main (int argc, char *argv[]) {
	unsigned int r;
	
	srandomdev();
	/* use this on non-BSD systems:
	srandom(time (0));
	*/
	
	r = random () % 99999 +1;
	printf ("%d\n", r);
	
	return r;
}


More information about the freebsd-questions mailing list