If you chose to srand
, it is a good idea to then call rand()
at least once before you use it, because it is a kind of horrible primitive psuedo-random generator. See Stack Overflow question Why does rand() % 7 always return 0?.
srand(time(NULL));
rand();
//Now use rand()
If available, either random
or arc4rand
would be better.