I'm making a text-based RPG (Sure you haven't heard that one before ;))

So I'm trying to randomize the damage that the player deals.
I want the damage to be (strength*2) + a random number between the variables mindamage and maxdamage, how do I do that?

Yeah, I tried that:

srand(time(0));
                        
                        DMG = rand() / (RAND_MAX / maxdmg + 1) + mindmg + (str*2);
                        
                        etemphp -= DMG;

But it doesnt randomize :(

use this equation :

long Rand(int min, int max){
		return long ( (float)rand()/RAND_MAX * (max-min) + min );
	}

Here is some ref.

I tried this and get the error-message: a function-definition is not allowed here before '{' token


How do I then apply this to the game?