Hello, I am trying to write a program that counts how many dice rolls are needed to get a yahtzee(all dice with the same number) but when I try to run it, it seems like it gets stuck in a loop. Can someone help me find what's causing this?
Code:
#include <cstdlib>
#include <ctime>
#include <iostream>
using namespace std;
bool diceroll(int *pcount)
{
const int size=5;
int high=7, low=1, dice[size];
bool yahtzee=false;
for (int i=0; i<size;i++)
{
dice[i]=rand()%((high+1)-low)+low;
}
for (int j=0;j<size;j++)
{
if(dice[j]!=dice[j+1])
break;
if (j==5)
{
return true;
*pcount++;
}
}
*pcount++;
return false;
}
int main()
{
int count, *p_count=&count;
bool yahtzee=false;
srand(time(NULL));
while(yahtzee==false)
{
yahtzee=diceroll(p_count);
}
}