Mail Archives: djgpp/1998/01/15/14:31:15
From: | "Geoff J. Howard" <howard AT duke DOT usask DOT ca>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | rand() problem
|
Date: | Thu, 15 Jan 1998 13:02:57 -0600
|
Organization: | University of Saskatchewan
|
Lines: | 29
|
Message-ID: | <Pine.OSF.3.96.980115125749.12355A-100000@duke.usask.ca>
|
NNTP-Posting-Host: | duke.usask.ca
|
Mime-Version: | 1.0
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Hello All,
I am just new to the djgpp world of C computing and I tried out a
simple random number program and kept getting the same "random" number
generated all the time, which is either 0 or no number. Is this a known
problem? I have included the code below. I am thinking that it could be as
a result of my computer not having enough RAM, what is the minimum amount
I should have to run djgpp properly. Thanks all
Geoff
#include <stdio.h>
#include <stdlib.h>
main ()
{
int i;
for (i=1; i<= 20; i++) {
printf("%10d", 1 + (rand() % 6));
if (i % 5 == 0)
printf("\n");
}
return 0;
}
- Raw text -