If I don't specify srand(), what seed does rand() use?

前端 未结 5 1569
借酒劲吻你
借酒劲吻你 2020-12-11 18:44

Here is the code:

#include 
#include 
#include 

int main(void)
{
    int r;
    int i;
    for (i = 0; i < 1         


        
5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-11 18:56

    If rand() is called before any calls to srand() are made, the same sequence shall 
    be generated as when srand() is first called with a seed value of 1.
    

    Ref:

    http://pubs.opengroup.org/onlinepubs/009695399/functions/rand.html

提交回复
热议问题