home *** CD-ROM | disk | FTP | other *** search
- #include <libc.h>
- #include <sys/time.h>
- #define MAXRND 2147483649
- extern long random();
- extern void srandom();
-
- int getRand(int MaxVal)
- {
- struct timeval tp;
- struct timezone tzp;
-
- gettimeofday(&tp, &tzp);
- srandom((int) tp.tv_usec );
- return(MaxVal * ((float) random()/(float) MAXRND) + 1 );
- }
-
-