title: Program for deck of cards compiles but crashes when running (c++)
body: <p>i tried to write a program that prints out all the cards in a deck but it crashes i tried removing the for loop in the main function and manually asigning the value to one card for the deck and then printing it and then it worked, but with the whole code compiler doesnt see any errors and runs just fine only to crash, whats the problem? im using DevC++ as the compiler</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  using namespace std;
  
  
  struct card
  {
          
      int num;
      string type;
      
      
      void printcard()
      {
          cout&lt;&lt;num&lt;&lt;&quot; &quot;&lt;&lt;type;
      }
  };
  
  card deck[52];
  
  void printdeck()
  {
      for (int f=0; f&lt;=52; f++)
      {
          deck[f].printcard();
      }
  }
  
  int main()
  {
      
     
     int J,Q,K,A;
      J=10;
      Q=10;
      K=10;
      A=11;
     int num[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K, A};
     string type[] ={&quot;Jvari&quot;, &quot;Yvavi&quot;, &quot;Guli&quot;, &quot;Aguri&quot;};
      
      
      int k=0;
      for(int i=0; i&lt;=4; i++)
      {
          for(int j=0; j&lt;=13; j++)
          {
              deck[k].num = num[j];
              deck[k].type = type[j];
              k++;
          }
      }
      
      printdeck();
      
     return 0;
  }
  </code></pre>