Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Jun 2003 18:51:26 +0200
From:      Simon Barner <barner@in.tum.de>
To:        "Jack L. Stone" <jackstone@sage-one.net>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Running a rand or random script
Message-ID:  <20030616165126.GB529@zi025.glhnet.mhn.de>
In-Reply-To: <20030616164242.GA529@zi025.glhnet.mhn.de>
References:  <3.0.5.32.20030616111517.0137e538@sage-one.net> <20030616164242.GA529@zi025.glhnet.mhn.de>

next in thread | previous in thread | raw e-mail | index | archive | help

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;
}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030616165126.GB529>