I don't understand why i keep getting the same random number for player and computer. I am rolling a die twice, once for player and then for the computer and I am doing it via a function called roll_a_dice
Plz ignore the other variables they're irrelevant to my question.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int roll_a_dice (void);
int main(int argc, const char * argv[]) {
int round=1, playerScore, playerTotal, computerScore, computerTotal;
int player, computer;
do{
printf("Welcome to the Yacht game.\nLets see who is lucky!\n");
player=roll_a_dice ();
computer=roll_a_dice ();
printf("Player: %d – Machine: %d\n",player, computer);
}while (player!=computer||computer!=player);
while(round!=12){
round++;
}
return 0;
}
int roll_a_dice (void){
srand(time(NULL));
return 1 + rand() % 6;
}