|
From: Ian H. <Ia...@ma...> - 2003-03-21 09:35:31
|
The following is a bit of C code that uses the current time as a seed.
It's an example I have so it may have bits you will need to modify
(Namespaces and .h files etc.)
But it does work.=20
/*
** Program to demonstrate the use of the rand function
*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(int argc, char *argv[])
{
int nCount;
int nRandom;
/* Seed random number generator with current time */
srand((unsigned)time(NULL));
/* Display 20 random positive integers */
for(nCount=3D0; nCount<20; nCount++)
{
nRandom=3Drand();
printf("%d ", nRandom);
}
=20
system("PAUSE");
return 0;
}
|