I am asking to see if there is a way of increasing the speed the srand(time(NULL));
function "refreshes"? I understand srand()
produces a new seed according to time (so once a second), but I am looking for an alternative to srand()
that can refresh more often than 1 second intervals.
When I run my program it produces the result it is supposed to, but the seed stays the same for essentially a second, so if the program is run multiple times a second the result stays the same.
Sorry for such a simple question, but I couldn't find an answer specifically for C anywhere online.
gettimeofday()
instead oftime()
if you need more than second accuracy. This is completely orthogonal tosrand
. – Unformedrand
. – Winebaum