delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/11/09/21:17:57

From: Nate Eldredge <neldredge AT hmc DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: random number generator
Date: 09 Nov 2000 18:09:17 -0800
Organization: InterWorld Communications
Lines: 26
Sender: nate AT mercury DOT st DOT hmc DOT edu
Message-ID: <83aeb8efxu.fsf@mercury.st.hmc.edu>
References: <GnIO5.10922$Wd3 DOT 1222073 AT typhoon DOT mn DOT mediaone DOT net>
NNTP-Posting-Host: mercury.st.hmc.edu
Mime-Version: 1.0
X-Trace: nntp1.interworld.net 973822158 50483 134.173.57.219 (10 Nov 2000 02:09:18 GMT)
X-Complaints-To: usenet AT news DOT interworld DOT net
NNTP-Posting-Date: Fri, 10 Nov 2000 02:09:18 +0000 (UTC)
User-Agent: Gnus/5.0802 (Gnus v5.8.2) Emacs/20.5
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

"tritesnikov" <tritesnikov AT hotmail DOT com> writes:

> Ok, so I'm trying to create a program which uses a random number generator
> for dice.  When I seed the random number I use "
> 
> srand(time(0));
> a = rand() % 5;
> 
> This is more or less the standard way of doing a simple random number.  The
> problem is when I compile the program it gives me the error:
> 
> Error: implicit declaration of function 'int time(...)'
> 
> Does anyone know how to fix this?

#include <time.h>

"implicit declaration" means you used a function without declaring it,
which for standard functions usually means you forgot to include its
header.  The man page for each function will tell you what header it's
declared in.

-- 

Nate Eldredge
neldredge AT hmc DOT edu

- Raw text -


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