Well, after reading some source code, I wrote a text blackjack ( nothing too fancy, bare essentials ) and I compiled it. Compiles just fine, but when I try and run it, it closes immediately. What am I doing wrong?
Thanks in advance.Code:/**************************************** * Text BlackJack Game * Author: Cloud6 * Level: Beginner ****************************************/ #include <iostream> using namespace std; //declare player structure struct Player { unsigned int money; unsigned int wins, losses; bool won, lost; }; Player player; void play(); int main() { //declaring needed variables unsigned short input; unsigned short a = 0; //setting default stats player.money = 600; player.wins = 0; player.losses = 0; player.won = false; player.lost = false; //begin game cout<<"Welcome to Text BlackJack"<<endl; while(a) { cout<<"\n\nPlease select your option."<<endl; cout<<"1. Check money"<<endl; cout<<"2. Play"<<std::endl; cout<<"3. Review Status"<<endl; cout<<"4. Quit"<<std::endl; cin>>input; switch(input) { case 1: cout<<"You currently have "<<player.money<<" dollars at your disposal."; break; case 2: play(); a = 1; break; case 3: cout<<"\n\nWins: "<<player.wins<<" Losses: "<<player.losses<<"."; break; case 4: return 0; break; } a = 0; if (player.money == 0) { cout<<"Out of money there..."<<endl; cout<<"Press any key to quit"<<endl; system("pause"); return 0; } } return 0; } void play() { //actual code goes here // this part is not impoartant }



LinkBack URL
About LinkBacks


