From: MÃ¥rten Dolk Date: Thu, 19 May 2005 14:17:22 +0000 (+0000) Subject: Changed random seed to use usec instead of seconds X-Git-Url: https://ruin.nu/git/?p=popboot.git;a=commitdiff_plain;h=36283553b51149fc6d7a704ba4f746310aafa49b Changed random seed to use usec instead of seconds --- diff --git a/simprog.c b/simprog.c index a713847..8311d50 100644 --- a/simprog.c +++ b/simprog.c @@ -1,7 +1,7 @@ #include #include #include - +#include void print_help(char name[]) { @@ -37,6 +37,7 @@ int main (int argc, char** argv) int i, rand_value, sum; int retvals[100]; int percentages[100]; + struct timeval td; if (argc==2 && strcmp("--help",argv[1])==0 ) { @@ -52,7 +53,8 @@ int main (int argc, char** argv) /* Get random number in interval [0,100) */ - srand(time(0)); + gettimeofday(&td,0); + srand(td.tv_usec); rand_value = rand() % 100; /* See if we want to fire an "error" */