Random numbers

I'm making a rpg game, and working on the combat atm. How would I do a random number between 2 int's?

Like a bronze sword would do damage 1 - 3, while a iron sword would do 2 - 6.

1
2
3
4

srand(static_cast<short>(time(0)));
short sword1 = rand() % // (1 - 3) + 1;


Any ideas?
rand() % (max - min + 1) + min;
That gives me a low of 0, and a high of 6 when I do (5 - 2).
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
#include <ctime>
#include <cmath>

int main()
{
	int min = 3;
	int max = 5;
	std::srand(std::time(0));
	for (int i = 0; i < 10; i++)
	{
		int r = rand() % (max - min + 1) + min;
		std::cout << r << std::endl;
	}
}

Topic archived. No new replies allowed.