Professional Documents
Culture Documents
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <ctype.h>
#define MAXGUESSES 5
//this function prompts the player to make a guess and returns that
guess
//this function is called from inside the PlayOneRound ( ) function
described above
char GetGuess(void);
//this function takes two arguments, the guess from the player
//and the solution letter from the file.
//The function returns 1 if the guess matches the solution and returns
a 0 if they do not match
//This function also lets the user know if the guess comes
alphabetically before or after the solution
int CompareCharacters(char, char);
char letter;
//letter from file
//this for loop will allow the player to play more than one
game
//without recompiling
for (i = 0; i < numGames; i++)
{
printf("Let's play game %d", i + 1);
//get a solution letter from file - use fscanf
fscanf(inPtr, " %c", &letter);
//change the solution to uppercase
letter = toupper(letter);
//call the PlayOneRound function and pass it the
solution
PlayOneRound(letter);
}
//use conditions to let the user know if they won or lost the round of
the game
//this function takes two arguments, the guess from the player
//and the solution letter from the file.
//The function returns 1 if the guess matches the solution and returns
a 0 if they do not match
//This function also lets the user know if the guess comes
alphabetically before or after the solution
int CompareCharacters(char guess, char letter)
{
if (guess == letter)
{
printf("Good Job!\n");
return 1;
}
else
if (guess < letter)
{
printf("The letter you are looking for comes
after %c\n", guess);
return 0;
}
else
if (guess > letter)
{
printf("The letter you are looking
for comes before %c\n", guess);
return 0;
}
}