title: C program dice game
body: <p>I am in trouble with my dice game. I have a task:</p>
  
  <p>The rules of the game are the following:
  1. The player rolls the dice and adds up the face values.
  2. If the first roll is a 7 or 11, the player wins.
  3. If the first roll is a 2, 3 or 12, the player looses.
  4. If the first roll is any other number, that sum becomes the player's point.
  5. To win, the player must continue rolling the dice until he/she “makes point.”
  6. The player loses by rolling a 7 before the point. </p>
  
  <p>1) Define WON and LOST as macros in your program. Use the values of 0 for WON and 1 for LOSE
  2) Implement a function, with function prototype int rollDice( void );</p>
  
  <p>rollDice( ) should use rand( ) to randomly generate a number between 1 - 6</p>
  
  <p>return the number generated by rand( )</p>
  
  <p>3) Implement a function, with function prototype int playGame( void ); </p>
  
  <p>When the player is ready to play, (s)he would use the key ENTER to roll the dice</p>
  
  <p>If the user wins in his/her first roll, congratulate the player and return with WON</p>
  
  <p>If the user looses in his/her first roll, congratulate the player and return with LOSE</p>
  
  <p>Let the user keep playing until (s)he wins / loses, give an appropriate massage and finish the game with the last roll value.</p>
  
  <p>4) Your main( ) should
  Call your function playGame( )</p>
  
  <p>Ask the user if (s)he wants to continue playing another game, keeping track of the numbers of losses and wins</p>
  
  <p>When the user decides to finish playing, display the number of wins and losses (s)he had.</p>
  
  <p>Give the user an appropriate message depending on the number of wins or losses (s)he had</p>
  
  <p>Return with a value of EXIT_SUCCESS</p>
  
  <p>Here is what I have now, but it tells me that there are mistakes. Can anyone please help me with this task?</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;ctype.h&gt;
  #include &lt;time.h&gt;
  #include &lt;stdlib.h&gt;
  
  #define WON 0
  #define LOSE 1
  
  int rollDice(void);
  int playGame(void);
  
  int rollDice(void) {
      return ((rand() % 6) + 1);
  }
  
  int playGame(void){
    int dice_1 = 0;
    int dice_2 = 0;
    int sum = 0;
    time_t t;
    srand(time(&amp;t));
    printf("ROLL THE DICE WITH [ENTER]\n");
    dice_1 = rollDice();
    dice_2 = rollDice();
    sum = dice_1 + dice_2;
    if (sum == 7 || sum == 11){
     printf("Congratulations you roll %d and WON at your first try!", sum);
    }
    else {
      printf("Your roll was %d ,you lose try agian.\n", sum);
    }
    return 0;
  }
  
  int main (void){
    playGame();
  }
  </code></pre>
  
  <p>The Error is (in gcc linux):</p>
  
  <p>x.c:9:1: error: stray ‘\302’ in program</p>
  
  <p>int rollDice(void);</p>
  
  <p>^</p>
  
  <p>x.c:9:1: error: stray ‘\240’ in program</p>
  
  <p>x.c:10:1: error: stray ‘\302’ in program</p>
  
  <p>int playGame(void);</p>
  
  <p>^</p>
  
  <p>x.c:10:1: error: stray ‘\240’ in program</p>
  
  <p>x.c:12:1: error: stray ‘\302’ in program</p>
  
  <p>int rollDice(void) {</p>
  
  <p>^</p>
  
  <p>x.c:12:1: error: stray ‘\240’ in program</p>
  
  <p>x.c:16:1: error: stray ‘\302’ in program</p>
  
  <p>int playGame(void){</p>
  
  <p>^</p>
  
  <p>x.c:16:1: error: stray ‘\240’ in program</p>