Menu for Hangman

Hi,
I am working on a menu for my hangman game. I have three options:

-New User which asks user to enter details and save to a binary file (done)
(here I used struct and normal file classes fstream etc)

-Existing user - here I need to display all usernames present in the binary file for the player to select by entering the number near the particular username. Each struct will have name, age, score (which will be updated at the end) and last word used (which also will be updated at the end). This Part I am working on.

-Delete User (still need to do)

I need some hints for what is the best way to implement this an maybe some examples if it is possible.

Brandon



Hmm, well this particular problem(Existing User), will require lots of reading and writing to files, so I hope your comfortable with doing that :)

Well you should have a file created that stores each persons username(ExistingUsers.txt). Then every-time someone makes a new user, you write their username to this file. After you've created this file It's time to create individual files for every user. Let's say I named myself Guesstimate. You would need to write my username to the ExistingUser file, and create another file with my Username(Guesstimate) as the title. In here, you would store my Name, Age , Score, and last-word(I guess last word is the last word guessed?).

NewUser -> Write NEW_USERNAME to EXISTING USER FILE -> Create Separate File For the User(eg. Guesstimate.txt), which stores their name, age, score, and last-word guessed.
Last edited on
If I were to write everything in one file, would there be any advantages as regards to efficiency of system resources? If yes would it be significant? This my main concern.

thanks
If I were to write everything in one file, would there be any advantages as regards to efficiency of system resources?


Well, it would look better in one file than having to open and read several files to obtain information(Each file takes up certain amount of bytes based on size). It's really up to you. Just make sure it is organized and easy to maintain.

If yes would it be significant?


Yep.
Hi again,
I managed to get the menu working with new user, select user and update entries at the end of each game in a single binary file. My problem now is that when I delete a user profile from the program i am left with only white space. When I go to select users again, I see my deleted entry as: 0 0 .. How can I shift my contents upwards to remove all the white space please?
Topic archived. No new replies allowed.