| delorie.com/archives/browse.cgi | search |
| From: | "Jared Davis" <jared AT underdark DOT net> |
| Newsgroups: | comp.os.msdos.djgpp |
| Subject: | Re: random() error? |
| Date: | Fri, 2 Apr 1999 07:07:01 -0600 |
| Organization: | Posted via RemarQ Communities, Inc. |
| Lines: | 47 |
| Message-ID: | <923058321.875.90@news.remarQ.com> |
| References: | <7e1lhb$qkt$1 AT news DOT snowcrest DOT net> |
| NNTP-Posting-Host: | 204.248.23.136 |
| NNTP-Posting-Date: | Fri, 02 Apr 1999 13:05:21 GMT |
| X-Trace: | 923058321.875.90 WIDUGOAMN1788CCF8C usenet1.supernews.com |
| X-Complaints-To: | newsabuse AT remarQ DOT com |
| 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 |
I think you need to use:
short k = random() % 52;
instead.
Jared
--
[ jared AT underdark DOT net ]
[ jared AT neonramp DOT com ]
Richard Lohuis <richhlo AT snowcrest DOT net> wrote in message
news:7e1lhb$qkt$1 AT news DOT snowcrest DOT net...
> I'm having a problem with generating random numbers.
>
> I'm taking a class on C++ OOB programming, the text & class are geared
> toward Borland Turbo C. I finally had to get a copy just to make sure
that
> some error I run into are mine. usually the case, but the following
snippet
> runs on TC:
>
> ;
> ;
> randomize(); // seed random number generator
> for( j=0; j<52 ;j++ ) // for each card in the deck,
> { short k=random(52); // pick another card @ random
> Card temp=Deck[k]; // & swap them
> Deck[j]=Deck[k];
> Deck[k]=temp;
> }
> ;
>
> It states: Error: too many arguments to function 'random()'
> pointing directly to "random(52)"
> In 'stdlib.h', the corresponding highlight is:
> long random(void);
> Looks to me like it won't take an argument.
> beings I typed it out of the book I'm now confused, TC takes it, DJGPP
> won't.
> Thanks in advance,
> richhlo AT snowcrest DOT net
>
>
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |