And, if you want a more "random" seed, if RDRAND is not available, you can change SRAND_() like this:
Of course, all this only works on "unix"...Code:static void SRAND_(void) { int fd; unsigned int rnd; ssize_t size; if ( ( fd = open( "/dev/urandom", O_RDONLY ) ) < 0 ) { perror("open"); goto fallback; } if ( ( size = read( fd, &rnd, sizeof rnd ) ) != sizeof rnd ) { if ( size < 0 ) perror("read"); close( fd ); goto fallback; } close(fd); srand( rnd ); return; fallback: // In case of failure, use the timestamp anyway... srand( time( NULL ) ); }