Possible Duplicate:
What’s the Right Way to use the rand() Function in C++?
Hi all, I'm trying to set up a random number generation function in c++. Im trying to set it up so that it generates a number between 1 & 500. Right now it returns integers in order according to the system clock, I need TRUE random numbers. Can anyone help?? This is what i have so far:
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main ( )
{
srand( time (0) );
int min = 1, max = 500, randNumber;
randNumber = 1 + rand( ) % 500;
cout << randNumber << endl;
system("pause");
return 0;
}