#include <cs50.h>
#include <stdio.h>
#include <ctype.h>
int main()
{
int iRandD1 = 0;
int iRandD2 = 0;
int totalD = 0;
srand(time(iRandD1));
srand(time(iRandD2));
//use random numbers to assign values to each die
iRandD1 = (rand() % 6) + 1;
iRandD2 = (rand() % 6) + 1;
if ((iRandD1 + iRandD2) == 7 || (iRandD1 + iRandD2) == 11)
{
printf("player wins\n");
}
else
{
printf("%d", totalD);
}
}
There is my code for a dice game that predicts the sum of the two dice when rolled. I include the ctype.h
library for the srand(time())
, I include but this error keeps coming up.
/home/ubuntu/workspace/fooling/ $ make dice
clang -ggdb3 -O0 -std=c11 -Wall -Werror -Wshadow dice.c -lcs50 -lm -o dice
dice.c:10:11: error: implicit declaration of function 'time' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
srand(time(iRandD1));
^
1 error generated.
make: *** [dice] Error 1
any help with the solution?