Re: Read System Clock in Windows



Moikel said:

Hello,

I'm writing a program that requires that I generate random numbers. I'm
using the C rand()function. I want to use the system clock as a seed
for the function.

http://c-faq.com/lib/srand.html

How do I read the system clock in Windows?

time()

(Please
state any libraries I'm going to need etc).

The standard library, which is linked in by default so you don't need to
worry about it.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
.



Relevant Pages

  • [PATCH] /dev/time for Linux, inspired by Plan 9
    ... reading or writing text strings to a special file named /dev/time. ... epoch seconds, nanoseconds since start of epoch, ... /dev/time sets the system clock to the given number of epoch seconds. ... +that is provided by the Plan 9 operating system from Bell Laboratories. ...
    (Linux-Kernel)
  • [PATCH] /dev/time for Linux, inspired by Plan 9
    ... reading or writing text strings to a special file named /dev/time. ... nanoseconds since boot, and nanoseconds per second. ... to /dev/time sets the system clock to the given number of epoch seconds. ... +that is provided by the Plan 9 operating system from Bell Laboratories. ...
    (Linux-Kernel)
  • Re: Read System Clock in Windows
    ... I'm writing a program that requires that I generate random numbers. ... I want to use the system clock as a seed ... But the OP should be concerned about including the correct header. ... Remove del for email ...
    (comp.lang.c)
  • Re: Read System Clock in Windows
    ... I'm writing a program that requires that I generate random numbers. ... How do I read the system clock in Windows? ... I can imagine some things you need high resolution timing for, but seeding a RNG isn't one of them -- and if you do need that for some reason, you should probably use your own RNG in the first place, rather than use rand. ...
    (comp.lang.c)