hello i have a problem with my blackjack game it was working befor i added a few new functions that allow a split to happen.
the problem is the only thing ive changed is that it now can check if a split can happen(badly at that) the problem seems to be an access to far into an array error?
heres some code that might be causing the problem
thats one function here is the other it could be fromCode:while((a.stick==false)&&(a.bust==false))
{
if ((checksplit(a.myHand))==true)
{
cout<<"you can split. would you like to?y/n\n";
char tempa;
cin>>tempa;
if (tempa=='y')
{ *gamestate=splitstate;
}
//system("pause");
}
char answer;
cout<<"would you like to 's'tick or 't'wist\n";
cin>>answer;
if (answer=='s')
{
a.stick=true;
answer='o';
}
if (answer=='t')
{
system("cls");
a.twist(ndeck.drawCard());
a.handValue();
for (int j=0;j<b.cardcount;j++)
{
cout<<b.myHand[j].value<<b.myHand[j].suit<<" ";
}
cout<<endl;
for(int i=0;i<a.cardcount;i++)
{
cout<<a.myHand[i].value<<a.myHand[i].suit<<" ";
}
cout<<endl;
if(a.value>21)
{
a.bust=true;
}
answer='o';
}
}
if((a.stick==true)&&(a.bust==false))
{
*gamestate=dealerturn;
return;
}
if (a.bust==true)
{
Sleep(1000);
*gamestate=whowon;
return;
}
}
the array only has 5 in it and cant have any more or less than thatCode:bool checksplit(card thand[])
{
for (int i=0;i<5;i++)
{
for (int j=0;j<5;j++)
{
if (j!=i)
{
if ((thand[i].value)==(thand[j].value)&&(thand[i].value)>0)
{
return true;
}
}
}
}
return false;
}