So I am new to C++ and learning all alone... until now everything went fine, but i am learning how to use rand() and the result does bother me a little...
So my goal is to generate a random number for the HP of a player at the beginning of a game. To be fair, I set up a minimal HP of 50 points and I want to create a random number with 50 being the minimal and 200 the maximum.
int HP = 50 + rand() %200;
cout << HP;
Now, the problem is:
The program always give me the same int
.
To check the result i created a new project and only displayed the rand()
number with the same values, and I got the same result -> 91
.
this mean, I would say int HP = 91;
would be exactly the same.
Practice and trial being the key to learn (I think) I tried the same rand()
values on 5 new projects, always the same number...