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
#include <iostream>
#include <string>
using namespace std;
struct card
{
int num;
string type;
void printcard()
{
cout<<num<<" "<<type;
}
};
card deck[52];
void printdeck()
{
for (int f=0; f<=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[] ={"Jvari", "Yvavi", "Guli", "Aguri"};
int k=0;
for(int i=0; i<=4; i++)
{
for(int j=0; j<=13; j++)
{
deck[k].num = num[j];
deck[k].type = type[j];
k++;
}
}
printdeck();
return 0;
}