You are not logged in.
I'm fairly new to programming and I just started learning about file access..
This program reads a highscore-list from a file, prints it, asks for a new highscore entry (player and score), sorts it into the list and writes the number of highscore-entries and all the entries to a file in binary mode.
This program would be perfect for a really boring game, because if the game is really boring you just play it a few times and you would never notice the problem with it, because when you start this highscore-function after adding the 6th entry to the list, it prints some weird stuff..
This is the code.
http://pastebin.com/m5d66a62f
I would be really thankful for any help
Offline
You have troubles with index :
1) the entries var in main function
2) i and j in the sort function
About sort, you should also check out the Bubble sort on wikipedia.
Note that in your specific case, you don't need a full sort, you only need to sort one variable at each step.
Finally, you should check out what happens when giving wrong / very long entries for Player or Score.
pacman roulette : pacman -S $(pacman -Slq | LANG=C sort -R | head -n $((RANDOM % 10)))
Offline
Thanks alot for your help. Got everything working the way I want now
Offline
Thanks alot for your help. Got everything working the way I want now
Cool, I hesitated to send a little patch, but I thought you could probably figure it out yourself
But now, I'm curious, could you post your fixed version?
pacman roulette : pacman -S $(pacman -Slq | LANG=C sort -R | head -n $((RANDOM % 10)))
Offline
http://pastebin.com/m35c271fe
That's what I did before I started reading about ncurses
I don't know if there is any possibility to have safe input in normal C++. Any suggestions would be appreciated
Offline
It's a bit better than before, but it's not there yet
if (entries < 10) {
blabla
else if (entries == 10) {
blabla
That covers all normal cases, so the two others else are never run.
Because when your program is used correctly, you always have entries <= 10 .
pacman roulette : pacman -S $(pacman -Slq | LANG=C sort -R | head -n $((RANDOM % 10)))
Offline