www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/08/28/06:05:41

Newsgroups: comp.os.msdos.djgpp
Date: Fri, 22 Aug 1997 13:55:46 -0700
From: Daniel Koepke <dkoepke AT california DOT com>
Subject: Re: Random numbers...
In-Reply-To: <5tepnq$2h5$1@news.kode.net>
Message-ID: <Pine.BSI.3.95.970822134738.10841A-100000@global.california.com>
References: <01bcaa71$4c08c200$0d5e4ec2 AT xyy> <5telqi$1ue$1 AT news DOT kode DOT net> <5tepnq$2h5$1 AT news DOT kode DOT net>
MIME-Version: 1.0
NNTP-Posting-Host: 140.174.210.7
Lines: 31
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

On 20 Aug 1997, Heathen wrote:

-+             #include <dos.h>
-+
-+             main(){
-+             int C;
-+             struct time time_struct;
-+             gettime(&time_struct);
-+             C = time_struct.ti_hund;
-+             printf("%d",time_struct.ti_hund);
-+             }

Or, you could...

  #include <time.h>

  #define RAND(min,max) ((random() % (max-min+1))+min) 
  void main()
  {
    srand(time(0));
    printf("A random between 1-1000: %d\n", RAND(1,1000));
  }

Not the best of the best of the pseudo-random number generators, but not
terrible.


--
Daniel Koepke -:- dkoepke AT california DOT com -:-  [Shadowlord/Nether]
Think.

- Raw text -


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