### Help with poker game

I have to make a sort of poker game where 5 random cards are selected. The user can choose to replace whichever cards, and then the program tells them what their hand is.

The problem I am having is the part where the user is asked to discard whichever cards they choose and they are replaced. I can make a for loop which asks the user which they want to discard, but I can't figure out how to get rid of those cards and replace them.

The user would have to input the face and suit and that card would have to be removed. If I can figure that out then replacing it shouldn't be too bad.

The program works fine without the discarding part.

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273`` ``````#include "stdafx.h" #include #include #include #include #include #include #include using namespace std; short convert_value(string value); //converts card face to a value, 2=2, jack=11, king=13 etc. bool straight(short value[]); //checks if cards make a straight bool same_suit(string suit[]);//checks if cards make a flush void check(bool& four, bool& three, bool& pair, bool& two_pair, short combos[], short& size); //checks if cards make 3 of a kind, pairs, etc. void xx(short value[], short num_of_combos[], short& size);//checks for multiple occurences or something, dont really know, given to me by partner int _tmain(int argc, _TCHAR* argv[]) { srand(time(NULL)); string cardval[13]; cardval[0]="A"; cardval[1]="2"; cardval[2]="3"; cardval[3]="4"; cardval[4]="5"; cardval[5]="6"; cardval[6]="7"; cardval[7]="8"; cardval[8]="9"; cardval[9]="10"; cardval[10]="J"; cardval[11]="Q"; cardval[12]="K"; string suit[4]; suit[0]="H"; suit[1]="D"; suit[2]="C"; suit[3]="S"; string card1val=cardval[rand()%13]; string card1suit=suit[rand()%4]; string card2val=cardval[rand()%13]; string card2suit=suit[rand()%4]; string card3val=cardval[rand()%13]; string card3suit=suit[rand()%4]; string card4val=cardval[rand()%13]; string card4suit=suit[rand()%4]; string card5val=cardval[rand()%13]; string card5suit=suit[rand()%4]; cout<
I didn't take a too in-depth look at your code, so what I say below not be what you are looking for or might not help, but here goes.

With how you have it set up, you would probably have to add a bunch of if statements. As such below:

This assumes user has inputted what they want to remove and stored it in:
strings removeVal and removeSuit
 ``12345678910111213141516171819`` `````` if(card1val[0] == removeVal[0] && card1suit[0] == removeSuit[0]) { card1val=cardval[rand()%13]; card1suit=suit[rand()%4]; } else if(card2val[0] == removeVal[0] && card2suit[0] == removeSuit[0]) { card2val=cardval[rand()%13]; card2suit=suit[rand()%4]; } ... ... ... else if(card5val[0] == removeVal[0] && card5suit[0] == removeSuit[0]) { card5val=cardval[rand()%13]; card5suit=suit[rand()%4]; } else { //card not found }``````

 ``12345`` ``````struct card { int val; char suit; }; // Or whatever data types ``````