//The following program I wrote is a guessing game
//program. The program chooses a random number, which the user should
//attempt to guess. Hints are given to the player instructing him/her
//that the guess is too high or too low. The program ends if either
//the correct number is guessed, or the user does not guess the number
//within 10 tries. If the user guesses the correct number, the
//program proceeds to reports
//a. the number of tries it took to guess the number.
//b. The incorrect guesses made by the user.
//Using structures I declared a data-type called struct PlayingPerson.
//This structure should keep track of a player's name and score.
//The score is defined to be the number of guesses the user needed to guess the correct answer.
//The struct PlayingPerson should be given an alternate name Player,
// using the typedef statement.
//A file called HighScores.dat should contain the name and
//score of the player with the lowest score.
//(Note: the lower the score, the better the player).
//The first thing your game should do is open this file and
//read in the name and score contained within it. Also, the
//current player's name should be read in from the keyboard.
//After the game is ended, the score of the current player
//is compared with that read in from the file.
// If the score of the current game is less than that read
//in from the HighScored.dat file, the current name and score
//are recorded in the HighScores.dat file, thereby replacing
//the old data in it. If this is the first time the program is run,
//the file HighScores.dat does not exists yet.
//If then your program attempts to open this file,
//it will fail. In this case the file should be created at
//the end of your program, and the current score and name recorded
typedef struct playingperson player;
void populate (player &populateplayingperson);
void print (player printplayingperson);
int main ()
int zero =0;
cout<<"I've got a number from 1 to 100, can you guess it?"<<endl;
cout<<"Your Guess: ";
if (guesses[y] > mynumber)
if (zero == 10)
cout<<"Guess Lower."<<endl<<endl<<"Guess again"<< endl;
else if (guesses[y] < mynumber)
if (zero == 10)
cout<<"Guess Higher."<<endl<<endl<<"Guess again" << endl;
cout << "Congratulation YOU GOT IT!!" << endl;
cout<<"Guess "<<x+1<<" was: "<<guesses[x]<<endl;
cout<<"The correct answer is: "<<mynumber<<endl;
cout << "You guessed " << zero << " times." << endl;
void populate(player &populateplayingperson)
cout<<"Players Name: "<<endl;
cout<<"Players number of guesses: "<<endl;
void print (player printplayingperson)
cout<<"Players Name: "<<player.playersname<<endl;
cout<<"Players number of guesses: "<<player.score<<endl;
I can not seem to get this to work correctly. Could someone steer me in the right direction. Any help would be appreciated.