SRAND Number Generation Help
I am spending too much time wrapping my head around srand() without success. I need some help around this simple little bit. Here is my timely dilemma...
These are my includes:
#include <cstdlib> //For srand() and rand().
#include <ctime> //For time().
My initializations:
int gameTime = 1200;
double randomTime;
srand(time(0));
randomTime = (rand() % 1000) + 1;
My (supposedly working) generator:
gameTime = randomTime - gameTime;
In the body:
cout << "Do not forget, your current time is: " << gameTime << " minutes.\n";
Dilemma:
The output keeps going back and forth between these two numbers:
Do not forget, your current time is: -660 minutes.
Do not forget, your current time is: 1200 minutes.
And back to 1200 again.
It is supposed to be going from 1200 down to 0, randomly subtracting numbers.
Thank you for any help with this bit. I have been meaning to ask this for months, just been busy.
> Christian. Italian. Warrior. BS-GSP major. Gamer. Borg... I am that hero!
> La resistenza è, ed è stato sempre, inutile.
> Christianity is a lifestyle, not a “religion", with Jesus the Christ, Lord & Savior. Nothing has disproved any Biblical facts. In fact, science & archeology have done nothing but proved it all instead. Therefore, pizza party with the Man & I bring the colas!
> POSTING COMMENT * I may reply back in hours to months (unless improperly locked on me) due to duty schedule. I reply as fast as I can to anything still open I am involved in. Thank you.