c++ - picking rand() number from 1-6 -
this question has answer here:
i have simple problem here no clue how fix this! trying create number generator want pick random number 1-6. no zeros! question marked dup shouldn't because c++ not c:
srand(static_cast<unsigned int>(time(0))); int dice = rand()%6;
rand() % 6
gives number in range 0..5
. add 1 range 1..6
.
Comments
Post a Comment