This is a blackjack program using array. It works in Devc++ but doesn't work in visual C++.I think I am missing some kind of header files could anyone help me out?
my email is ....
thanks
#include <iostream>
#include <ctime>
#include<iomanip>
#include <string>
using namespace std;
void deal(int,int&,int& ,int[][2],int&,int[][2] );
void deal(int,int&,int&,int&,int[][2],int&,int[][2] );
int getbet(int);
void filldeck(int[][2],int);
void shuffle(int[][2],int);
void printhand(int,int[][2]);
int main()
{string suit[4]={"hearts","diamonds","spades","clubs"};
string card[13]={"ace","2","3","4","5","6","7","8","9","10","jack","queen","king"};
int totdealer,totplayer,upto=0;
int money,bet,aces,decks=2,j;
int deck[52*decks][2];
int dealhand[20][2],playhand[20][2],playcards,dealcards;
char yesno='Y';
bool again;
srand(time(0));
filldeck(deck,decks);
/* cout<<"deck-defore shuffled:\n";
for(j=0;j<52*decks;j++)
cout<<card[deck[j][1]]<<"\t"<<suit[deck[j][0]]<<endl;
cout<<endl;
*/
shuffle(deck,decks);
/*cout<<"deck-after shuffled:\n";
for(j=0;j<52*decks;j++)
cout<<card[deck[j][1]]<<"\t"<<suit[deck[j][0]]<<endl;
cout<<endl;
*/
cout<<"How much money do you have? ";
cin>>money;
while(money>0&&toupper(yesno)=='Y')
{bet=getbet(money);
totdealer=0;
playcards=0;
dealcards=0;
cout<<"\nDealer cards\n";
deal(2,totdealer,upto,deck,dealcards,dealhand);
printhand(dealcards,dealhand);
aces=0;
totplayer=0;
cout<<"\nPlayer cards\n";
deal(2,aces,totplayer,upto,deck,playcards,playhand);
printhand(playcards,playhand);
cout<<"\nYour total is "<<totplayer<<endl;
cout<<"You have "<<aces<<" aces"<<endl;
again=false;
while(totdealer<21&&totplayer<21&&!again)
{
cout<<"\ndo you want another card? ";
cin>>yesno;
if(toupper(yesno)=='Y')
{cout<<"\nPlayer cards\n";
deal(1,aces,totplayer,upto,deck,playcards,playhand);
printhand(playcards,playhand);
cout<<"\nYour total is "<<totplayer<<endl;
cout<<"You have "<<aces<<" aces"<<endl;
}
else
again=true;
}
cout<<"Dealer total: "<<totdealer<<endl;
cout<<"Your total: "<<totplayer<<endl;
if(totdealer>totplayer||totplayer>21)
money-=bet;
else if(totdealer<totplayer&&totplayer<=21)
money+=bet;
cout<<"\nGame over\nYou have $"<<money<<" left\n";
if(money>0)
{cout<<"\nPlay again (Y/N)?";
cin>>yesno;
}
}
system("pause");
return 0;
}
void printhand(int m,int deck[][2])
{int i;
string suit[4]={"hearts","diamonds","spades","clubs"};
string card[13]={"ace","2","3","4","5","6","7","8","9","10","jack","queen","king"};
for(i=0;i<m;i++)
cout<<card[deck[i][1]]<<"\t"<<suit[deck[i][0]]<<endl;
}
void deal(int num,int& tot,int& upto,int deck[][2],int& m,int p[][2])
{int i,n;
for(i=0;i<num;i++)
{n=deck[upto][1];
n++;
if(n>10)
n=10;
p[m][1]=deck[upto][1];
p[m][0]=deck[upto][0];
m++;
if(n==1)
tot+=11;
else if(n>=10)
tot+=10;
else
tot+=n;
upto++;
}
}
void deal(int num,int& aces,int &tot,int& upto,int deck[][2],int& m,int p[][2])
{int i,n;
for(i=0;i<num;i++)
{n=deck[upto][1];
n++;
if(n>10)
n=10;
p[m][1]=deck[upto][1];
p[m][0]=deck[upto][0];
m++;
if(n==1)
{aces++;
tot+=11;
}
else if(n>=10)
tot+=10;
else
tot+=n;
upto++;
}
if(tot>21)
if(aces==0)
return;
else
{aces--;
tot-=10;
}
}
int getbet(int money)
{int bet;
cout<<"You have $"<<money<<" enter your bet: ";
cin>>bet;
while(bet>money)
{cout<<"You cannot bet more then you have!!!\n";
cout<<"You have $"<<money<<" enter your bet: ";
cin>>bet;
}
return bet;
}
void shuffle(int deck[][2],int decks)
{
int i,num1,type1,num2,type2,temp;
for(i=0;i<100*decks;i++)
{num1=rand()%(13*decks);
num2=rand()%(13*decks);
type1=rand()%4;
type2=rand()%4;
temp=deck[type1][0];
deck[type1][0]=deck[type2][0];
deck[type2][0]=temp;
temp=deck[num1][1];
deck[num1][1]=deck[num2][1];
deck[num2][1]=temp;
}
}
void filldeck(int deck[][2],int decks)
{
bool cards[4][13][decks];
int i,j,k,num,type,d;
for(i=0;i<4;i++)
for(j=0;j<13;j++)
for(k=0;k<decks;k++)
cards[i][j][k]=false;
for(j=0;j<52*decks;j++)
{do
{
num=rand()%13;
type=rand()%4;
d=rand()%decks;
}while(cards[type][num][d]);
deck[j][0]=type;
deck[j][1]=num;
cards[type][num][d]=true;
}
}