lundi 27 février 2017

Randomize function

I am trying to create a 1000 elements array. Each element should range between 0 and 99. I first tried by reproduce this didactic example:

#include <stdio.h>
#include <stdlib.h>
#define DIM 1000

int myVect[DIM];
int i;
int main(){
randomize();                       /∗ Initialize randomize*/
    for (i =0; i < DIM ; i ++)
        myVect[i] = random(100);
return 0;
}

While compiling, I got error, warning and note.

warning: implicit declaration of function ‘randomize’    (1)
error: too many arguments to function ‘random’           (2)
/usr/include/stdlib.h:282:17: note: declared here        (3)

I found resources from two posts:

Unfortunately, because of my inexperience, I am not capable of get the meaning of the didactic example I posted.

(1) In which library is randomize? I have not been able to find out.

(2) Random should not have a parameter. Hence, why in the example it comes with 100, as it should determine the range of the random numbers?

(3) Does this note indicate where random is declared?

Thank you for your patience.




Aucun commentaire:

Enregistrer un commentaire