Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.c    |    Meh, in C you gotta define EVERYTHING    |    243,242 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 242,878 of 243,242    |
|    Tim Rentsch to John McCue    |
|    Re: srand(0)    |
|    07 Jan 26 07:39:08    |
   
   From: tr.17687@z991.linuxsc.com   
      
   John McCue writes:   
      
   > Michael Sanders wrote:   
   >   
   >> Is it incorrect to use 0 (zero) to seed srand()?   
   >>   
   >> int seed = (argc >= 2 && strlen(argv[1]) == 9)   
   >> ? atoi(argv[1])   
   >> : (int)(time(NULL) % 900000000 + 100000000);   
   >>   
   >> srand(seed);   
   >   
   > I like to just read /dev/urandom when I need a random   
   > number. Seem easier and more portable across Linux &   
   > the *BSDs.   
   >   
   > int s;   
   > read(fd, &s, sizeof(int));   
      
   Apples and oranges. Many applications that use random numbers   
   need a stream of numbers that is deterministic and reproducible,   
   which /dev/urandom is not.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca