delorie.com/archives/browse.cgi | search |
From: | "Marp" <Marp AT 0 DOT 0 DOT 0 DOT 0> |
Newsgroups: | comp.os.msdos.djgpp |
Subject: | Re: (char) rand(); !? |
Date: | Thu, 15 Apr 1999 14:34:09 -0400 |
Organization: | Netcom |
Lines: | 15 |
Message-ID: | <7f5bf8$h9k@dfw-ixnews12.ix.netcom.com> |
References: | <37161bd0 DOT 16276943 AT news DOT luebeck DOT netsurf DOT de> |
NNTP-Posting-Host: | prn-nj1-09.ix.netcom.com |
X-NETCOM-Date: | Thu Apr 15 1:34:16 PM CDT 1999 |
X-Priority: | 3 |
X-MSMail-Priority: | Normal |
X-Newsreader: | Microsoft Outlook Express 5.00.2014.211 |
X-MimeOLE: | Produced By Microsoft MimeOLE V5.00.2014.211 |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Reply-To: | djgpp AT delorie DOT com |
^Hawk^ <Hawk AT DarkSoft DOT Net> wrote in message news:37161bd0 DOT 16276943 AT news DOT luebeck DOT netsurf DOT de... > Hello there ! ;) > > Why does "dont_care[0]=(char) rand();" give me always the same output > and how can I get _really_ random results !? > > Bye, ^Hawk^ - the DarkSoft-Productions @ www.darksoft.net You must seed the rand() function at the start of your program to get different results each time. At the start of your program put srand(time(0)) You only need to have these functions called once. Read the documentation on rand() and srand() in libc.inf.
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |