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

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -