Может кто-нибудь сказать мне, почему эти функции не дают мне результат в разумном спектре?
Полный код, который я использую, приведен ниже, он должен симулировать игру в кости и распечатывать детали для пользователя и позволять делать ставки, если пользователь этого желает. Все работает, кроме самой игры в кости. Вместо того, чтобы выполнять цикл только тогда, когда с crapsResult не связано значение истинности, он находит одно действительное значение и непонятную строку из одного отрицательного числа. Любая помощь будет оценена.
int main()
{
//Declare the user input variables
int gamesPlayed = 0;
char inputPrint = ' ';
char isBetting = ' ';
int startingBet = 0;
//Declare the variables used by the program
int endingBet = 0;
int currentGame = 0;
bool crapsResult;
int gamesWon = 0;
int gamesLost = 0;
double percentWon = 0;
bool detailPrint = false;
//Prompt the user to input their variables
cout < "Enter the number of games to be played: ";
cin >> gamesPlayed;
while(gamesPlayed < 1)
{
cout < " Error: must be greater than 0" < endl;
cout < "Enter the number of games to be played: ";
cin >> gamesPlayed;
cin.clear();
cin.ignore();
}
cout < "Do you wish to print details (Y/N): ";
cin >> inputPrint;
if(inputPrint == 'y' || inputPrint == 'Y')
{
detailPrint = true;
}
cout < "Do you wish to bet (Y/N): ";
cin >> isBetting;
if(isBetting == 'y' || isBetting == 'Y')
{
cout < "Enter money to start betting with: ";
cin >> startingBet;
while(startingBet < 1)
{
cout < " Error: must be greater than 0" < endl;
cout < "Enter the number of games to be played: ";
cin >> gamesPlayed;
cin.clear();
cin.ignore();
}
}
//Seed the random number generator
srand(time(NULL));
//Set a value for ending bet
if(startingBet == 0)
{
endingBet = 1;
}
else
{
endingBet = startingBet;
}
//Call playcraps to simulate the game for as many games as the user input
for(currentGame = 1; currentGame