hmm....Asimov wrote:Hi all,
I have been reading to get a better random number you can set the seed to the clock time of your computer with something like
unsigned seed = time(0);
srand(seed);
and you have to include #include <time.h> to use it.
I am not 100% certain how it works, but it might help.
Asimov
PS I am not even sure yet why unsigned is used over int LOL, but there you go.
Well, I've encountered this method many times before, it's pretty much just setting the random number seed to the amount of seconds since January 1970 or something
I'm pretty sure you can just do this
Code: Select all
#include <ctime>
#include <iostream>
#include <cstdlib>
int main()
{
srand(time(NULL));
}
a signed short, or just short is an integer from -32768 to 32767
while an unsigned short is an integer from 0 to 65535
this is how you use them
Code: Select all
short sn; // -32768 - 32767
unsigned short usn; // 0 - 65535
just a quick note
Asimov,
when you include c libraries into a C++ application, most people do it like this
Code: Select all
#include <ctime>
Code: Select all
#include <time.h>