vendredi 7 juillet 2017

srand(time(NULL)) in main not working

my main is:

int main()
{
   srand(time(NULL));
 ...
}

in one of my functions i do this loop:

for (i = 0; i < CODE_LENGTH; i++)
{
    code += to_string((rand() % 9) + 1);
}

and for some reason code always turns out to be 6985

CODE_LENGTH is defined to be 4 anyone knows why?




Aucun commentaire:

Enregistrer un commentaire