|
-
Jun 22nd, 2002, 02:24 PM
#1
Thread Starter
Addicted Member
Problem with random number generator
This code keeps giving me the same random number, can somone please tell me why?
{
int RandomNumber;
int i;
int j;
for (i = 0; i < SCREEN_HEIGHT; i++) /*For the number of rows on the console*/
{
for (j = 0; j < SCREEN_WIDTH; j++)/*For the number of columns on the console*/
{
//Sleep();
srand(time(NULL));
RandomNumber = 1 + (int) (3.0 * rand() / (RAND_MAX + 1.0));
switch (RandomNumber)
{
case 1 : write_char('1');
break;
case 2 : write_char('0');
break;
case 3 : write_char(' ');
break;
}/*switch (random_number)*/
}
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|