when the following function runs, it goes straight through without stopping. it also prints out what isn't needed, help please.
game::gamble()
{
char guess;
cout<<"Winning a gamble wins 5 credits\n";
gambleval = (rand () % 10) + 1; //generates random number for gamble function
cout<<" "<<gambleval<<endl;
cout<<"Higher or lower? correct guess wins.(H for high, l for low)\n";
cin>>guess;
if (guess == 'h')
{
cout<<"You have guessed higher\n"; //tells player what they guessed
}
else
{
cout<<"You have guessed lower\n";
}
gambleval2 = (rand () % 10) + 1; //generates second random number for gamble function
if (gambleval2 >= gambleval && (guess == 'h'))
{
{
cout<<"You guessed correct\n"; //if the second number is greater than the first, then it works this out and
credadd =5; //tells the user they guessed correctly or not
}
}
else
{
cout<<"You guessed wrong\n"; //tells the user they guessed wrong in the circumstances
}
if (gambleval >= gambleval2 && (guess == 'l'))
{
{
cout<<"You guessed right\n"; //if the second number was smaller than the first then this works it out and
credadd = 5; //tells the user they guessed correctly
}
}
else
{
cout<<"You guessed wrong\n"; //tells the user they guessed wrong under the circumstances
}
addcredit(); //calls the update credit function to update the amount of credits in case the player wins
}