Recommended way to initialize srand?

前端 未结 15 1940
夕颜
夕颜 2020-11-22 08:07

I need a \'good\' way to initialize the pseudo-random number generator in C++. I\'ve found an article that states:

In order to generate random-like

15条回答
  •  天命终不由人
    2020-11-22 08:58

    if you need a better random number generator, don't use the libc rand. Instead just use something like /dev/random or /dev/urandom directly (read in an int directly from it or something like that).

    The only real benefit of the libc rand is that given a seed, it is predictable which helps with debugging.

提交回复
热议问题