What code can I use to generate a random number in C++?

Discussion in 'Programming' started by ChristianEater, Dec 19, 2011.

  1. #1
    I want to generate a random number (1 -12), and see if it matches a smaller group of numbers (1 -3). Basically, I need a code to test hit chance for a text-based game.

    If you had an Accuracy of 3, I want the program to pick a random number (1 -12), and if the number is between 1 and 3, the hit lands.

    Sadly, I'm new to programming. I'm so used to batch scripting and would appreciate any help.
     
    ChristianEater, Dec 19, 2011 IP