Hi,
I have a program that generates a random number for each run of a loop, like this:
<snippet>:
int i;
int n;
for(i=0;i<=10;i ++){
n = rand() / (RAND_MAX / 10 + 1);
printf( "n: %d\n", n );
}
Obviously using the time to seed rand() each run wouldn't work because progressing through the loop ten times does not take a second of time. So how would I go about seeding rand() in my program to get 10 different random numbers in my loop?
Thanks,
Sake
I have a program that generates a random number for each run of a loop, like this:
<snippet>:
int i;
int n;
for(i=0;i<=10;i ++){
n = rand() / (RAND_MAX / 10 + 1);
printf( "n: %d\n", n );
}
Obviously using the time to seed rand() each run wouldn't work because progressing through the loop ten times does not take a second of time. So how would I go about seeding rand() in my program to get 10 different random numbers in my loop?
Thanks,
Sake
Comment