I need a good seed for an RNG

How do I get a good seed for a random number generator? I think I need a function similar to 'clock' in 'time.h', but it should return the number of clock ticks since the computer started, so it doesn't return the same number every time.
add:
 
 #include <time.h>  


add:
 
 srand((unsigned)time(NULL)); 

(before you call rand();)
That only generates a different seed every second. I need a function that changes the seed faster than that.
I think the correct code is:
1
2
3
4
5
6
srand(unsigned(time(NULL)));
//then you should use an array where you assign the random values
long A[20];
for(int i=0;i<20;i++)
{A[i]=rand();
}

This should assign the vallues more faster.
I mean the seed, not the random numbers generated from it.
Is there a way you could manipulate your random results using a loop and math expressions for each second that the clock is seeding your generator?
That's the only thing I can think of trying, since I don't know how else to seed the generator.
Is there a way you could manipulate your random results using a loop and math expressions for each second that the clock is seeding your generator?
That's the only thing I can think of trying, since I don't know how else to seed the generator.
try
1
2
3
4
5
6
7
int seed;
for(seed=1;;seed++);
{
srand(seed);
seed = rand();
printf("%d\n",seed);
}


hope it helps
This is far better: http://xkcd.com/221/
Topic archived. No new replies allowed.