i have strange behavior in which i try to generate random numbers and they sometimes totally the same , or there is problem if they created on the same time? using VC 2012
for (int i = array_size; i < (array_size); i++)
{
srand((unsigned int)time(NULL));
int rw = rand() % 960 + (20); //returns a pseudo-random integer between x resolution size 0 -> width
int rh = rand() % 640 + (20); //returns a pseudo-random integer between x resolution size 0 -> height
lwsl_notice("c:%d width %d height %d\n",c, rw, rh);
c++;
}
The output is :
[2016/06/30 09:39:09:7274] NOTICE: c:0 width 606 height 567
[2016/06/30 09:39:09:7274] NOTICE: c:1 width 606 height 567
[2016/06/30 09:39:09:7274] NOTICE: c:2 width 606 height 567
[2016/06/30 09:39:09:7274] NOTICE: c:3 width 606 height 567
Aucun commentaire:
Enregistrer un commentaire