I have about 6 players... and calling this function for each player.. Is there a way to joint it together? So i can just call it depending on the player?
like dealplayer(1); or dealplayer(2);
Code:void dealplayer1 (){ player1.count++; double R = (double)rand()/(double)RAND_MAX; double P; player1.card = cards[rand() % 52]; while (isalpha(player1.card)) player1.card = cards[rand() % 52]; cards[player1.card] = 'X'; if (player1.card >= 11) player1.cardnew = 10; else player1.cardnew = player1.card; strcpy(player1a[player1.count], cardnames[player1.card]); player1.total += player1.cardnew; P = (double)1 - (((double)21 - (double)player1.total)/(double)21); if (R >= P) player1.play = 0; else player1.play = 1; if (player1.total >= 21) player1.play = 1; } void dealplayer2 (){ player2.count++; double R = (double)rand()/(double)RAND_MAX; double P; player2.card = cards[rand() % 52]; while (isalpha(player2.card)) player2.card = cards[rand() % 52]; cards[player2.card] = 'X'; if (player2.card >= 11) player2.cardnew = 10; else player2.cardnew = player2.card; strcpy(player2a[player2.count], cardnames[player2.card]); player2.total += player2.cardnew; P = (double)1 - (((double)21 - (double)player2.total)/(double)21); if (R >= P) player2.play = 0; else player2.play = 1; if (player2.total >= 21) player2.play = 1; }