Is it good idea to pass uninitialized variable to srand?

前端 未结 5 2047
醉梦人生
醉梦人生 2021-01-20 02:19

Is it good idea to pass uninitialized variable to srand instead of result of time(NULL)?
It is one #include and one function call

5条回答
  •  南笙
    南笙 (楼主)
    2021-01-20 02:33

    It's not a good idea. Undefined behaviour doesn't guarantee that you won't get the same seed on every run, which would be bad for randomness. It doesn't guarantee that your processor won't halt and catch fire either.

提交回复
热议问题