PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Random Numbers ....

Working on my first Pocket PC Game ... and have run into into an unexpected brick wall. Using Embedded Visual C++ 3.0 is there any way to seed the random number generator with the current time?

srand( (long)time() ); will not work because time() (and time.h for that matter) is unsupported in win ce 3.0 as far as the help docs would tell me. How would I go about getting random numbers that are different each time the program is run?

Thanks, Eyez
On the Pocket PC you can use:

srand(GetTickCount());

GetTickCount() returns the number of milliseconds that has passed since Windows CE was started.

/Johan
Awesome ... thanks a mil!