I wrote this function to generate random numbers and return it to the calling function
int getCard(void)
{
int range;
int card;
srand(time(NULL));
range = (10 - 1) + 1;
card = rand() % range + 1;
return card;
}
the calling function is....
int first2(void)
{
int firstCard;
int secondCard;
int total;
firstCard = getCard();
secondCard = getCard();
total = firstCard + secondCard;
printf("\n\nYour first card is a %d, and your second card is a %d.\n", firstCard, secondCard);
printf("The total for the hand is %d.", total);
return total;
}
but for some reason firstCard and secondCard always have the same value. I am not sure why. Can anyone help me out?