I am making this small program wich generates random numbers in order to make random sums. I checked the toturial to see how to generate random numbers using the system time, wich is never the same ofcourse. The problem is that I need to generare multiple random numbers at exactly the same time.
This is a piece of code I used. It will generate differend numbers IF the user does not press enter 3 times a second..
cout<<"Strike any key to generate first value";
cin.get();
time_t x;
time(&x);
srand((unsigned int)x);
sumvalueA = rand() % (lowX-highY/lowX)+lowX;
cout<<"Strike any key to generate second value";
cin.get();
int sumvalueB=0;
time_t y;
time(&y);
srand((unsigned int)y);
sumvalueB = rand() % (lowX-highY/lowX)+lowX;
cout<<"Strike any key to generate random sum";
cin.get();
int randomsum=0;
time_t z;
time(&z);
srand((unsigned int)z);
randomsum= rand() % (randsumX-randsumY/randsumX)+randsumX;
The outcome was 3 different values when the user waited a while before pressing a key, but faster pressing a key would make the same values.
Is there a different way of creating random numbers, without having to use the system time??