Scoreboard saved in .txt file?
I've been sort of making a tiny game to learn the basics in C programming where the computer generates an array of four unique, random numbers and then the player tries to guess those four numbers.
I'm pretty much done with the game itself, but i also need a scoreboard for it, that saves your name and what score you received. I'm guessing this should be saved to a .txt file that can later on be read and displayed through the game.
I'll paste what i've done so far unto pastebin, so you can see what im talking about... Translated all the variable names to english, wrote them in swedish at first, but i think i got all of them.
One of the requirements is that the function control() must look like it does now:
void control(Secret secretNumber, Secret Guess, char help)
What im having problems with is that i dont really know how to make the scoreboard...
In the function "control" it checks if your guess is correct and if it is it will call the function "addToScoreboard" which will recieve the number of guesses you've made, ask for your name and then write the name and number of guesses to a .txt file...
I have basic understanding of how to write to a textfile, but i dont really know how to use it to create a scoreboard. After an entry with name and points has been made, how can i retrieve it if i want to show the top 10 entries on the scoreboard for example?
I also need to sort the scoreboard with the bubblesort so that the person with the best score is at the top.
I made a typedef struct for a "Player", with points and name as variables as im guessing this is what i'll need to use when creating the scoreboard?
I'll paste the code on pastebin, im guessing thats better than pasting it all here...
Im not surprised if you find some of the coding confusing, just remember im still learning! :)