Hello everybody,

an exercises of mine: it's a "guess the number" game.
The repetition of the game is given by a char variable: when the player guess the number I aks him/her if he/she want to play again, but the relative scanf is "ignored" and I don't see why.

I putted two additional printf to control number (no time to guess every time I make a try to fix the bug) and to control the value of the repetition char variable.

This 's the code...



Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int not_guessed(int real_number, int player_guess);


int main (void)
{/************/

   int number, guess;
   char play_again = 'y';

   srand(time(NULL));

   number = 1 + rand() % 1000;

   /* This printf should be cancelled once bug is fixed  */
   printf("%d\n", number);

   printf("I have a number beetween 1 and 1000\n"
          "Can you guess my number?\n"
          "Please type your first guess: ");

   scanf("%d", &guess);

   while (play_again == 'y') {

      while ( guessed(number, guess) == 0)
         scanf("%d", &guess);

      printf("Would you like to play again? (y o n)");


   /* This printf should be cancelled once bug is fixed  */
      printf("\n%c\n", play_again);

      scanf("%c", &play_again);
   }

   return 0;
}



int guessed(int real_number, int player_guess)
{/*******************************************/

   if ( player_guess < real_number)
      printf("Too low. Try again: ");
   else if (player_guess > real_number)
      printf("Too high. Try again: ");
   else
      printf("Excellent! You guessed the number\n");

   return  real_number == player_guess ;

}
Thank you...