J
jw
hi all;
i have a function like this,
it always rands the same number and gives error if i take the srand
function out of the for loop
void list::getWords()
{ int num;
for(int m=0;m<20;m++)
{
srand((unsigned)time( NULL ));
num=(rand()%41)-1;
node *ptr;
ptr=new node;
ptr->word=wordsall[num];
append(ptr);//appends to the linked list
}
}
i have a function like this,
it always rands the same number and gives error if i take the srand
function out of the for loop
void list::getWords()
{ int num;
for(int m=0;m<20;m++)
{
srand((unsigned)time( NULL ));
num=(rand()%41)-1;
node *ptr;
ptr=new node;
ptr->word=wordsall[num];
append(ptr);//appends to the linked list
}
}