yet another random num guestion
Im trying to get a group 20 random numbers with no duplicates
I thought my code is right to do this, but i still am getting duplicates. What changes should I make? Any help is greatly appreciated.
Here my random number function:
void random (info data)
{
int count, counta, n, go, num[20];
for (count = 0; count < 20; count++) num[count] = 0;
srand ((unsigned)time(NULL));
for (count = 0; count < 20; count ++)
{
go = 0;
do
{
n = (rand() % 50);
for (counta = 0; counta < 20; counta++)
{
if (num[counta] == n) go = 0;
else go = 1;
}
}
while (go ==0);
num[count] = n;
}
out (num, data);
}