GUYS IM GOIN MAD

Posts 1–4 of 4 · Page 1 of 1
GUYS IM GOIN MAD
im still a newbie with C++ , just started learning yesturday, and now this thing is goin to make me mad, why the fuck it tells me to break?? where is my mistake??????? it tells me the variable play is being used without being initialized :S
#include <iostream>
#include <ctime>
using namespace std;

int main()
{
srand(time(NULL));
int coins = 10,bet,chance,call;
bool play;
char choise;
while(play == true)
{
cout<<"Coins ="<<coins;
cout<<endl;
cout << "Enter a bet : ";
cout <<endl;
cin>>bet;
cout<<endl;
cout<<"Call heads or tails? h/t "<<endl;
cin>>choise;
cout<<endl;

if(choise == 'h')
{
call=1;


}
else{
if(choise == 't'){

call = 0;
}


else{
cout<<"If you didnt choose, i will choose for you";
cout<<endl;
call = rand()%2;
}
}
chance = rand()%2;
if (chance == call)
{
cout<<"You won ";
cout<<endl;
coins = coins + bet;
cout<<"Coins ="<<coins;
cout<<endl;
}
else{
cout<<"You lost..";
cout<<endl;
coins = coins - bet;
cout<<"Coins ="<<coins;
cout<<endl;
}

cout<<"Do you want to bet again? ";
cout<<endl;
cin>>choise;
cout<<endl;
if(choise == 'y')
{
play = true;
}

}

system("pause");
return 0;

}
Code:
bool play;
char choise;
while(play == true)
Set play to true before using it.
Code:
int coins = 10,bet,chance,call;
I think something is not right there too (obivious the error atom0s already told'ya) .
Code:
bool play;
You must make bool play = ture;
Posts 1–4 of 4 · Page 1 of 1

Post a Reply

Similar Threads

Talk with us