Alright, so im storing a random number to a variable using the GetRand function from the tutorial. What im wanting to do is get a different random number assigned to that variable..
Please forgive the crude example program, im sure im missing a header or something. Id really appreciate any help that you all are willing to offer.
int GetRand(int min, int max)
static int Init = 0;
if (Init == 0)
* As Init is static, it will remember it's value between
* function calls. We only want srand() run once, so this
* is a simple way to ensure that happens.
Init = 1;
* rand() % N <- To get a number between 0 - N-1
* Then add the result to min, giving you
* a random number between min - max.
rc = (rand() % (max - min + 1) + min);
int number = getrand(1,12345);
cout<<"Your current random number is: "<<number<<endl;
cout<<"Enter '1' for a new number: ";
cout<<"Your new random number is: "<<number<<endl;