I know that time(0)
will return in seconds, but is there a way for it to return smaller values? I think they are called miliseconds, but not sure. I need to pass it for srand()
.
Reason is I made 2 threads communicate with each other, but they communicate so fast, that each second they send like 30 same message to each other and I need those random numbers to be different, so a different seed each "milisecond"
srand
more than once. Every time you do it, you effectively reset the random generator.