srand in D
    Ali Çehreli 
    acehreli at yahoo.com
       
    Sun Oct 31 17:02:00 UTC 2021
    
    
  
On 10/31/21 9:54 AM, pascal111 wrote:
> Hi! I'm C learner and found the high similarity between C and D, and was 
> converting C code into D
Welcome! :) In case it makes to your use cases, check out -betterC as well:
   https://dlang.org/spec/betterc.html
 > but couldn't get the equivalent of this C
> statement "srand(time(NULL));".
Just comment that line out. :) D's pseudo-random generators start 
randomized by default:
import std.stdio;
import std.random;
void main() {
   // Pick a number between [0,10)
   writeln(uniform(0, 10));
}
The documentation is at
   https://dlang.org/phobos/std_random.html
Ali
    
    
More information about the Digitalmars-d-learn
mailing list