I really am in the dark on this one. This is a function from my "zombie rabbits " program. I am trying to make a function that randomizes the chance of a baby being male female or zombie. I tried to use the same number generation code I used for a guess my number game and it's not working. Any and all help is appreciated.
The error message: In function 'void repopulate()':
82:26: error: too many arguments to function 'int rand()'
{
int babies;
babies = 1;
while(babies != 0){
int rabbitsex;
srand( time(0));
rabbitsex = rand(time)%20+1;
switch (rabbitsex)
{
case 1:
case 2:
case 3:
case 4:
case 5:
case 7:
case 8:
case 9:
case 10:
m++;
break;
case 11:
case 12:
case 13:
case 14:
case 15:
case 16:
case 17:
case 18:
case 19:
f++;
break;
case 20:
z++;
break;
}
babies--;
}
}
The random number generator that rand() uses has already been seeded with the current time on line 6.
rand(), as show in http://www.cplusplus.com/reference/cstdlib/rand/,takes in zero parameters and generates a random integer.
Doingint a = rand()%20; will make a be a random number in range [0, 19].