C++ code compiles but doesn't run : <p>I am currently writing a Texas Hold'em code in order to learn more about c++ and gain experience. But I recently ran into a problem in which I have no idea what to do.My code compiles just fine without errors but once I make it run and it arrive at a specific function it just stops working (as in I get an error from CodeBlock saying your program has stopped working). I have tried cutting out parts such as loops in the function to see which specific part is the problem but after a couple of days im still at a stop.
Here is the function and class that I believe is the problem:</p>

<pre><code>class Player{
string name;
int bank=100;
static string cards[53];
static string final_card[2][6];
static string table_cards[5];

public:
void set_name(string a){name=a;}
string print_name(){return name;}
void card_generator();
string set_cards(int c){return cards[c];}
int print_bank(){return bank;}
void set_final_card(int i, int max_i);
void print_cards(){for(int i=0;i&lt;6;i++){cout&lt;&lt;final_card[0][i]&lt;&lt;endl;}}
};

void Player::set_final_card(int i, int max_i){
srand(time(NULL));
int tempV = 17;//create temp cards
string tempCards[tempV];
int randNB[tempV];

int check1 = 0, tmp;
while (check1==0){
    for(int g=0; g&lt;tempV;g++){

        tempCards[g]=cards[rand()%53];
        check1=1;
        tmp = g - 1;
        for(int o=tmp; o!=0; o--){
            if (tempCards[g]==tempCards[o]){
              check1=0;
            }
        }

    }

}
int p=0,k;
while(p&lt;6){
    k=0;
    final_card[0][k]=tempCards[p];
    k++;
    p++;
}
while(p&lt;12){
    k=0;
    final_card[1][k]=tempCards[p];
    k++;
    p++;
}
while(p&lt;17){
    k=0;
    table_cards[k]=tempCards[p];
    k++;
    p++;
}
}
</code></pre>

<p>Here is the full code in case I am wrong of the source of the problem:</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;stdlib.h&gt;
#include &lt;ctime&gt;
using namespace std;

class Player{
    string name;
    int bank=100;
    static string cards[53];
    static string final_card[2][6];
    static string table_cards[5];

    public:
    void set_name(string a){name=a;}
    string print_name(){return name;}
    void card_generator();
    string set_cards(int c){return cards[c];}
    int print_bank(){return bank;}
    void set_final_card(int i, int max_i);
    void print_cards(){for(int i=0;i&lt;6;i++){cout&lt;&lt;final_card[0][i]&lt;&lt;endl;}}
};

    string Player::cards[53];
    string Player::final_card[2][6];
    string Player::table_cards[5];

int main () {
  int choice1=0, i, max_i, tempV;
  string username;

  cout&lt;&lt; "Welcome to Texas Hold'Em!\n1-Play\n2-Quit\n";//menu

  while((choice1!=1)&amp;&amp;(choice1!=2)){//Makes sure that user enters correct input```
    cin&gt;&gt;choice1;
    if ((choice1!=1)&amp;&amp;(choice1!=2)){
        cout&lt;&lt;"Invalid Input!\nTry again!\n";
    }
  }
  system ("cls");
  if (choice1==2){//End Program
    return 0;
  }
  cout&lt;&lt;"How many players?[2-6]"&lt;&lt;endl;
  while((i!=2)&amp;&amp;(i!=3)&amp;&amp;(i!=4)&amp;&amp;(i!=5)&amp;&amp;(i!=6)){//Makes sure that user enters correct input
    cin&gt;&gt;i;
    if ((i!=2)&amp;&amp;(i!=3)&amp;&amp;(i!=4)&amp;&amp;(i!=5)&amp;&amp;(i!=6)){
        cout&lt;&lt;"Invalid Input!\nTry again!\n";
    }
  }
  Player player[i];//creating array of players
  player[0].card_generator();
  max_i = i;//max_i is nb of players
  i--;//since arrays start at 0
  system("cls");

  player[0].set_final_card(i,max_i);
  player[0].print_cards();

  if (choice1==1) {//SET NAMES OF ALL PLAYERS
    for(i=0; i&lt;max_i; i++){
        cout&lt;&lt; "Whats your name?\n";
        cin&gt;&gt;username;
        player[i].set_name(username);
        cout&lt;&lt;"Your name is "&lt;&lt; player[i].print_name()&lt;&lt; " and you have "&lt;&lt;                 player[i].print_bank()&lt;&lt;"$\n";

        tempV=i+1;//used bc arrays start at 0
        if(tempV!=max_i){
            cout&lt;&lt; "Give PC to player "&lt;&lt; i+2 &lt;&lt;endl;
        }
        _sleep(3000);
        system("cls");
    }
  }

  return 0;
}

    void Player::set_final_card(int i, int max_i){
    srand(time(NULL));
    int tempV = 17;//create temp cards
    string tempCards[tempV];
    int randNB[tempV];

    int check1 = 0, tmp;
    while (check1==0){
        for(int g=0; g&lt;tempV;g++){

            tempCards[g]=cards[rand()%53];
            check1=1;
            tmp = g - 1;
            for(int o=tmp; o!=0; o--){
                if (tempCards[g]==tempCards[o]){
                  check1=0;
                }
            }

        }

    }
    int p=0,k;
    while(p&lt;6){
        k=0;
        final_card[0][k]=tempCards[p];
        k++;
        p++;
    }
    while(p&lt;12){
        k=0;
        final_card[1][k]=tempCards[p];
        k++;
        p++;
    }
    while(p&lt;17){
        k=0;
        table_cards[k]=tempCards[p];
        k++;
        p++;
    }
    }

    void Player::card_generator(){
    string card_value[13];
    card_value[0]="1";
    card_value[1]="2";
    card_value[2]="3";
    card_value[3]="4";
    card_value[4]="5";
    card_value[5]="6";
    card_value[6]="7";
    card_value[7]="8";
    card_value[8]="9";
    card_value[9]="10";
    card_value[10]="J";
    card_value[11]="Q";
    card_value[12]="K";

    string card_type[4];
    card_type[0]="of hearts";
    card_type[1]="of diamonds";
    card_type[2]="of clubs";
    card_type[3]="of spades";
    string card[53];
    int x=0;
    fill_n(card,53,0);

    for (int j=0;j&lt;4;j++){
      for (int q=0;q&lt;13;q++){
            card[x]=card_value[q]+" "+card_type[j];
            cards[x]=card[x];
            x++;

      }
    }
    }
</code></pre>

<p>If you have any criticism about the code itself even if not directly linked to problem feel free to tell me as I'm doing this to learn :D. Thank you in advance!!</p>
