ifstream f declares the filestream (input) f.open("game.dat") // looks for a file in current directory // with this name f.fail() // checks if the file was there and openable use f>> to get stuff from the file, just like cin f.close() // closes the fileYou program should take a date file that looks like game.dat and reads in the data. Read the data into the array players. A line is data for a player if it starts with P. If the line starts with Z, that is the end of the file. Print out the players with their scores. Output should look like this.
make159
make -f make159 csci159/lab5This makefile will create a new directory csci159 with a subdirectory called lab5, and it will populate that directory with some files that your instructor has provided. cd into that lab5 directory. Do an "ls". You are provided with a README. Read the README. You are also provided, in directory lab5, with files called makefile, and a data file "game.dat". cat these files; you can see that they have some data ready to be read in.
cp csci159dev/lab5/lab5.cpp csci159/lab5/.Now you can "cd csci159/lab5", and your lab5.cpp from your dev directory is now copied to your git-connected directory.
Enter 'P' new player, 'S' new or existing score for a player, or 'X' exit? <user enters 'w'> Enter 'P' or 'S' or 'X': <user enters either 'P' or 'p'> Enter new player's username: <user enters "funnygrl"> funnygrl is a new player, all scores are 0. Enter 'P' new player, 'S' new or existing score for a player, or 'X' exit? <user enters 'S' or 's'> Enter player's username: <user enters "ObiWan"> Player Obiwan does not exist. Enter 'P' new player, 'S' new or existing score for a player, or 'X' exit? <user enters 'S' or 's'> Enter player's username: <user enters "funnygrl"> Enter level: <user enters an integer between 1 and 4, say it is 2> Enter new Level 2 score for funnygrl (0 for score report): <user enters an integer between 0 and INT_MAX, say it is 300> 300 is a new high score for funnygrl at level 2! Recorded. Enter 'P' new player, 'S' new or existing score for a player, or 'X' exit? <user enters 'S' or 's'> Enter player's username: <user enters "funnygrl"> Enter level: <user enters an integer between 1 and 4, say it is 2> Enter new Level 2 score for funnygrl (0 for score report): <user enters an integer between 0 and INT_MAX, say it is 200> funnygrl has score of 300 at level 2. Enter 'P' new player, 'S' for new or existing score for a player, or 'X' exit? <user enters either 'P' or 'p'> Enter new player's username: <user enters "funnygrl"> funnygrl already exists. Enter 'P' new player, 'S' for new or existing score for a player, or 'X' exit? <user enters 'X' or 'x'> Thanks for playing!As usual, however, do not put a newline in between the program's prompt and the user's input. Look here for what that same interaction would look like on the screen.
make lab5xMake sure it gives you no errors or warnings. Warnings can cost you marks.
make cleanThis cleans up your directory of old executables. "ls" to see what remains.
make submitIf successful, you will see a variety of updates. The git version control program is copying your updated directory contents to a location where the instructor can view and mark it. There is a deadline programmed into git, so if you try to submit after the deadline, it won't let you. Up until that deadline, you can submit and it will keep track of the most recent version, which is the one your instructor will look at.