Home c SRAND Row Value (Time (NULL))

SRAND Row Value (Time (NULL))

Author

Date

Category

What does this line mean?

srand (Time (NULL));

Answer 1, Authority 100%

generates a random number using the current date, as a parameter, as if for unpredictable result)


Answer 2, Authority 250%

not quite as it was written. To generate pseudo-random numbers, the Rand () function is used. It generates numbers based on the base. If the database is not changed, the sequence of pseudo-random numbers will be the same. To set the base of the pseudo-random number generator, the SRAND () function is used. Its argument is the value of the base. A combination of Srand (Time (NULL) sets the current time as a base. This technique is often used so that with different launches of the pseudo-random number generator there was every time a different base and, accordingly, different row of obtained values.

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions