mercredi 21 janvier 2015

rand() gives back higher int than my max c++

So I hope I am not asking something stupid.


I want my program to pause for a random amount of ms going from 2000 to 5999 when a button is clicked so here is are the lines :



void ExpNatDlg::OnBnClickedBack()
{
int delayRand;
delayRand = (int)rand() % 6000 + 2000;
Sleep(delayRand);
}


To check the delays I get, I print them on a file, and I don't know why, I sometimes get delays higher than 7000 ms...


I don't know what I'm missing ! Thanks for your help!





Aucun commentaire:

Enregistrer un commentaire