samedi 22 juillet 2017

Using time to seed the randomizer in C with loops

I am using srand((unsigned)time(NULL)) to seed the randomizer in my C program. I noticed that when I create an array of random numbers using loops, all of the numbers will be the same if I put the seeder inside the loop instead of outside the loop. I assume this is because the loop runs extremely fast, but how does the seeder work to reseed the randomizer when it is outside of the loop? I am confused about how this is working in the program.




Aucun commentaire:

Enregistrer un commentaire