delorie.com/archives/browse.cgi | search |
From: | Endlisnis <s257m AT unb DOT ca> |
Newsgroups: | comp.os.msdos.djgpp |
Subject: | Re: Begginer question about Randomizing the timer. |
Date: | Mon, 17 May 1999 19:52:18 -0400 |
Organization: | BrunNet |
Lines: | 26 |
Message-ID: | <3740ABB2.7AB492B5@unb.ca> |
References: | <gH003.11822$r_1 DOT 7601956 AT newscontent-02 DOT sprint DOT ca> |
NNTP-Posting-Host: | ftnts4c38.brunnet.net |
Mime-Version: | 1.0 |
X-Mailer: | Mozilla 4.51 [en] (Win95; U) |
X-Accept-Language: | en |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Reply-To: | djgpp AT delorie DOT com |
Fire-Breathing Penguin wrote: > How do you get a random number? In QBASIC it would be done as > RANDOMIZE TIMER > X=INT(RND*10)+1 > . Is there any way to do the same in C/C++? #include<stdlib.h> #include<time.h> int main() { srand(time(0)); int x = rand(10)%10+1; return 0; } -- (\/) Endlisnis (\/) s257m AT unb DOT ca Endlisnis AT HotMail DOT com ICQ: 32959047
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |