Re: Random number (1,2,3)
- From: "David T. Ashley" <dta@xxxxxxxx>
- Date: Thu, 7 Dec 2006 13:53:11 -0500
"rhitx" <julimarjane@xxxxxxxxx> wrote in message
news:1165455688.545731.67390@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hello:
I'm trying create a random number generator, which will generate
either number 1, 2, 3.
I tried to do it like:
int random_number()
{
int no_goal, rand_Number;
rand_Number = rand();
no_goal = (rand_Number % 3);
return no_goal;
}
But it is only generating the digit "1", I don't see it changing to 2
or 3.
The problem may be, if you are calling it only once per program invocation,
that the library starts off with the same seed every time. Try calling it
maybe 10 times in one invocation of the program.
.
- References:
- Random number (1,2,3)
- From: rhitx
- Random number (1,2,3)
- Prev by Date: Re: Doubt in memcpy() and memset()
- Next by Date: Re: On-topicness
- Previous by thread: Re: Random number (1,2,3)
- Next by thread: round robin scheduler
- Index(es):
Relevant Pages
|
|