This is a program that is meant to be a dice game with the computer, and this is what I have so far. I'm trying to make sure that I'm doing it right but I can't compile it to check because of a syntax error near the end of the code, heres what I got.

#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;

int main()
{
	int dice, turnScore, scoreHuman;
	bool roll;
//10
	char r, s;
	bool turnOver, gameOver;
	srand((unsigned)time(0));

	r = true;
	s = false;

	gameOver = false;
	while(!gameOver)  {
//20
	
	  //Human's Turn
	  turnScore = 0;
	  turnOver = false;

	  do
	  {
		dice = (rand()%6)+1;

//30
	cout << "You rolled: " << dice;
	if(dice == 1)
	    {
		cout << "You lose your turn! Your total is " << scoreHuman;
		turnScore = 0;
		turnOver = true;
	    }
	else 
		{
//40
		turnScore += dice;
		cout << "Your turn score is " << turnScore << " and your total score is " << scoreHuman << endl;
		cout << "If you hold, you will have " << turnScore + scoreHuman << " points." << endl;
		cout << "Enter 'r' to roll again, 's' to stop.";
		cin >> roll;

		  if(roll = false)
		    {
			turnOver = true;
//50
		    }
		  else(roll = true);
		  
		}
	while(!turnOver);
		scoreHuman += turnScore;
		cout << "Your score is " << scoreHuman;
	
		if(scoreHuman >= 100)
		  {
//60
			cout << "YOU WIN!";
			gameOver = true;

			return 0; 
		  }
	    }
	  }

	return 0;
}

the error code is, "error C2059: syntax error : '}'" on line 68. The thing is, if I take that out, then I'm missing a right bracket to close the left bracket from line 7. I'm not sure how to fix this....

At first glance it looks like you've misplaced a right-bracket. You have put it on line 68, but it should be on line 55 (in front of while(!turnOver); ) to close your do {} while() loop.

Looks like you are missin a } on line 53 to close the do/while loop and you have one too many } at the end.

This question has already been answered. Start a new discussion instead.