   random number probs
  Im makin a text based game that involves you attacking the opponent. I cant work out how to make the attacking number between 1 and 7 random. also the opponent gets to have a shot at you.  how do i fix this?   
  I do it like this:#include <ctime> //Used for the 'time' in the 'srand()' functionint MyNum;int main(){    //Set up or 'seed' the generator. Only needs to be done once.    srand(time(NULL));  //Make a number between 0 and 6, and add 1 to make it 1 through 7    MyNum = (rand() % 7) + 1;   }(This is standard C++, which is what I guess you are using.)Hope that helps. ~S of the L~;  1 more thing i would like to know is: when it makes a random number, i want to take that number away from the opponents health and tell the player how much health the opponent has.   ;//include ctime and all other includes you are usingbool Quit;std::string EName; //Enemy's nameconst short int MaxHealth = 100; //Max enemy and player healthint PHealth; //Player's healthint EHealth; //Enemy's healthint PlayerDmg; //Player damageint EnemyDmg; //Enemy's damageint NUM; //Holds our random numberint PlayerDef; //Holds player defenseint EnemyDef; //Holds enemy's defenseint main(){    PHealth = MaxHealth; //Set up starting variables    EHealth = MaxHealth;    PlayerDmg = 8;    EnemyDmg = 5;    PlayerDef = 3;    EnemyDef = 3;   Quit = false;    EName = "skeleton";   srand(time(NULL)); //Set up random number generater(based off of 'time')   while(!Quit)    {   cout << "You were attacked by a " << EName << "!\n"; NUM = (rand() % PlayerDmg) + 1; //Makes a number between one and eight(PlayerDmg)   NUM -= rand() % EnemyDef; //Removes some of the damage due to the enemy's defense if(NUM < 0){NUM = 0;} //Ensures you don't deal a negative number of damage EHealth -= NUM; //Removes the damage from the enemy's health cout << "You dealt " << NUM << " to the " << EName << endl; //////////Enemy's turn//////////////////////////////////////   NUM = (rand() % EnemyDmg) + 1; //Makes a number between one and five(EnemyDmg)   NUM -= rand() % PlayerDef; //Removes some of the damage due to the player's defense if(NUM < 0){NUM = 0;} //Ensures you don't deal a negative number of damage   PHealth -= NUM; //Removes the correct amount of the player's health cout << "The " << EName << " hits you for " << NUM << " points of damage!\n";   if(PHealth <= 0){cout << "You were slain!\n"; Quit = true;}   else if(EHealth <= 0){cout << "You defeated the " << EName << "!\n"; Quit = true;}   cout << "The " << EName << " has " << EHealth << " health left.\n"   << "You have " << PHealth << " health points left.\n\n\n";    }    system("pause");    return 0;}This is a rough idea of how to do a few different things for your game. It'll cycle through, the player and the enemy trading blows until one dies(the enemy, unless real lucky, will be killed first) and then the program will exit.   