Possible Duplicate:
How to generate a random number from within a range - C
I want to generate a random number between 0 and 4 inclusively. How can I do this in c++?
Possible Duplicate:
How to generate a random number from within a range - C
I want to generate a random number between 0 and 4 inclusively. How can I do this in c++?
You could call std::rand(), usning the modulo operator to limit the range to the desired one.
std::rand()%5
You can also have a look at the new C++11 random number generation utilities
rand().