Rand shouldn't be turning up so many duplicates... for example, the following code
Code:
#include <stdlib.h>
#include <stdio.h>
#include <limits.h>
int main ()
{
int i;
srand(0);
for (i = 0; i < 20; i++) printf ("%d\n", rand());
printf ("\n\n");
return 0;
}
Produces no duplicates.
Code:
0
262236772
208042609
800207362
428428949
47718728
1793958355
1543227091
1255063701
1245922717
448084510
1841298076
1050803247
489249763
634882132
437249775
192858938
1769723075
2017244079
451954759
There's probably something in your code forcing the numbers to be the same.