time(0) is probably using miliseconds |
cppreference has this to say on the C library time function:
The encoding of calendar time in time_t is unspecified, but most systems conform to POSIX specification and return a value of integral type holding the number of seconds since the Epoch. |
https://en.cppreference.com/w/c/chrono/time
The C++ version of the C library time function says it somewhat differently, but time() is still measured in seconds.
Not that it really matters but time() can return -1 if the system time wasn't retrieved the return type is usually a signed arithmetic type. srand() wants an unsigned int as input, so without casting time() the compiler can complain with a warning.
Using the C library's srand()/rand() in C++ code isn't wrong, they just have issues. Especially when combined with using % to generate a random number within a range.
https://web.archive.org/web/20180123103235/http://cpp.indi.frih.net/blog/2014/12/the-bell-has-tolled-for-rand/
C++ has the <random> library, so any C++ code should use the C++ random facilities.
https://en.cppreference.com/w/cpp/numeric/random
What <random> adds to the coding toolbox is almost an embarrassment of riches, so many engines to choose from, each one using a different mathematical algorithm to generate a sequence of psuedo-random numbers.
Plus there are numerous distributions that replace the modulo clamping. Uniform for integers and floating point numbers so any number in the provided min-max range has as much of a chance to be chosen as any other. Other distributions for other statistical outcomes. A normal distribution is one that can produce the "bell curve" with the probability any given random number is more likely to be in the middle of the range.
The C++ standard has a number of predefined random number generators, with the ability to create others as needed.
Using the C++ random engines seems to be more complicated since there are so many choices available. Here's an older C++ working paper that is a good introduction, it helps demystify the usage:
http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2013/n3551.pdf