www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/05/17/17:16:53

Message-ID: <004001bc6307$6bf0df00$8ef8c6c3@johan>
From: "Johan Henriksson" <johan DOT he AT telia DOT com>
To: <djgpp AT delorie DOT com>
Subject: Re: ** Random error **
Date: Sat, 17 May 1997 23:10:23 +0200
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 4.72.3110.1
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
Reply-To: djgpp AT delorie DOT com

from Johan Henriksson, Sweden    HTTP://come.to/jhewok  |
Primary mail: johan DOT he AT telia DOT com                  #UIN 12035895
Second: jhe75 AT hotmail DOT com    Third: johan_he AT yahoo DOT com
Leadprogrammer and FX-specialist at Real software
http://come.to/real_software
*************************************************************************
-----Original Message-----
From: Börje Granberg <borje DOT granberg AT ebox DOT tninet DOT se>
Newsgroups: comp.os.msdos.djgpp
To: djgpp AT delorie DOT com <djgpp AT delorie DOT com>
Date: Monday, May 17, 1999 7:29 PM
Subject: SV: ** Random error **


>I tested it but there comes the same numbers evertime!
>

Japp, de missade några rader.
Du måste ge ett startvärde till randomiseraren. Tiden funkar bra:

#include <time.h>

Sen nånstans i början:

  srandom(time(NULL));

ps: Skaffa ICQ!!!

>
>
>
>Sean <sproctor AT enter DOT net> skrev i
>diskussionsgruppsmeddelandet:373EC6D5 DOT BD3882E0 AT enter DOT net...
>> "Börje Granberg" wrote:
>> >
>> > Can somebody tell how I do to set the variable "int i" to a random
>number
>> > from 1 to x?
>>
>> #include <stdlib.h>
>>
>> ...
>>
>> int i = rand() % x + 1;
>
>
>

- Raw text -


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