Help with RNG

I was designing a dice game where it rolls two dice and adds the values together to find the winner, you or the computer (not much of a game right? mostly just luck). Anyways, I had the program working and was using this to generate the random numbers:

int diceFace = 6;

int userRollOne = rand() %6;
int userRollTwo = rand() %6;

however, rand() %6 always comes out to 5, meaning im probably not doing it right. How am i supposed to generate random numbers within a certain range? Am i supposed to use arrays?
rand() is deterministic. If you don't use srand to seed it differently each time, you will get the same sequence over and over. If you use srand and time, you will get different values each time you run it.

note that x%6 gives a value from 0-5, so you should add 1 for a d6.
I finally figured it out just before you posted this, thank you though i appreciate it :)
Last edited on
Topic archived. No new replies allowed.