c - Is there a better function that rand()? -


i have program, in c, creates array of 1000 integers using random number 0-999 , performs sort of algorithm on array. in order test algorithm's running time, try running program 10000 times, every time run array same few arrays , changes. have used srand() function feed seed current time, still not help.

is there alternative solution rand() or way fix this? function is:

void getarray(int *ptr1,int size,int option){     int n;     srand(time(null));     for(n=0; n<size;n++)         *(ptr1+n) = *(ptr2+n)= rand()%1000;      } 

thanks in advance!

you should call srand once: on program startup.

right now, if call function multiple times before time changes sequence same.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -