delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/05/12/19:15:59

Date: Sun, 12 May 1996 19:09:44 -0400
From: dj (DJ Delorie)
Message-Id: <199605122309.TAA12416@delorie.com>
To: fred AT genesis DOT demon DOT co DOT uk
CC: djgpp AT delorie DOT com
In-reply-to: <831919995snz@genesis.demon.co.uk> (message from Lawrence Kirby on Sun, 12 May 96 16:53:15 GMT)
Subject: Re: Use of random

> >>    clock();             /* Initialize the clock */
> >>    (int *)ticks = clock();
> >>    srand(ticks);
> >
> >I don't think that will do what you were intending it to. If I'm not 
> >mistaken, the first time you call clock() it will zero the counter,
> 
> No, calling clock() doesn't affect the 'counter' at all, it simply
> reads whatever the current value is. There is certainly no guarantee that
> clock() returns 0 on the first time it is called. The correct way to use
> clock() is to call it twice and take the difference between the values.
> In that way it makes no difference where the zero point is.

The first time you call clock() or uclock() in an application, it
returns zero.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019