Hello
I wrote a function that generates 10 000 times a pair of different random numbers,
but somethimes i got bus errors.
(with out compiling twice, sometimes bus error, sometimes ok.... )
is the first time I got that time of errors..., it only appears sometimes, not always.
Does it have any relation with the number of iterations??
or something with time.h? or srand()? or rand?
here is part of my function.
Code:
unsigned long int iter=10000;
int seg1, seg2;
srand((unsigned int)time((time_t *)NULL));
for(i=0;i<iter;i++){
seg1=rand()%(nNodes-1);
do {seg2=rand()%(nNodes-1);}while(seg2==seg1);
/*make calculations... */
}
does it make any change if i put srand inside the for loop?
help please!...
thanks in advance.