| www.delorie.com/archives/browse.cgi | search |
| From: | d DOT vrabel AT n-shropshire DOT ac DOT uk (David Vrabel) |
| Newsgroups: | comp.os.msdos.djgpp |
| Subject: | Re: Random interger numbers |
| Date: | Tue, 24 Mar 1998 08:56:55 GMT |
| Organization: | Staffordshire University |
| Lines: | 17 |
| Message-ID: | <35177411.1984220@192.168.1.250> |
| References: | <01bd56dd$5d636c80$0f02000a AT frank DOT mtsu DOT edu DOT frank DOT mtsu DOT edu> |
| NNTP-Posting-Host: | www.n-shropshire.ac.uk |
| To: | djgpp AT delorie DOT com |
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
"Nathan Cournia" <nac2b AT frank DOT mtsu DOT edu> wrote:
>What I need is a function that will act as a (n) sided dice.
rand() returns an integer between 0 and RAND_MAX so use the mod (%)
operator.
eg.
return rand()%n
will return a number between 0 and n-1.
David.
David Vrabel d DOT vrabel AT n-shropshire DOT ac DOT uk
A poor student (aren't they all) at:
North Shropshire College
Oswestry, Shropshire, UK
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |