Mail Archives: djgpp/1998/11/29/09:55:30
From: | ams AT ludd DOT luth DOT se (Martin Str|mberg)
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Re: Randomizing
|
Date: | 26 Nov 1998 23:36:57 GMT
|
Organization: | University of Lulea, Sweden
|
Lines: | 54
|
Message-ID: | <73komp$59p$1@news.luth.se>
|
References: | <000701be197f$f2d2e100$79f5ffc2 AT default>
|
NNTP-Posting-Host: | queeg.ludd.luth.se
|
X-Newsreader: | TIN [UNIX 1.3 950824BETA PL0]
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
=?iso-8859-1?Q?Lazer_---=A4---?= (lazer_hassing AT yahoo DOT com) wrote:
: Denne opdelte meddelelse er i MIME-format.
:
: ------=_NextPart_000_0004_01BE1988.3AE538A0
: Content-Type: text/plain;
: charset="iso-8859-1"
: Content-Transfer-Encoding: quoted-printable
:
: Would anyone show me how to use rand()!!
:
: I nede to get it to chose from 2 numbers
:
: i've tryed this:
:
: ***********************************
: #include <stdio.h>
:
: int main()
: {
: int my_number;
: my_number=3Drand()%2;
: printf("%d", my_number);
: }
: ***********************************
The code is fine.
:
: It always print 0 on the screen
Yes. It's because you haven't seeded the generator with a call to
srand() yet. Read chapter 22.22 of the DJGPP FAQ and learn more.
:
: Thanks!!
:
: ---> Lazer
:
: ------=_NextPart_000_0004_01BE1988.3AE538A0
: Content-Type: text/html;
: charset="iso-8859-1"
: Content-Transfer-Encoding: quoted-printable
:
: <!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
: <HTML>
: <HEAD>
:
: <META content=3Dtext/html;charset=3Diso-8859-1 =
And stop this html rubbish, please.
Pettersson, Symphony No. 5,
MartinS
- Raw text -