There are multiple ways to do this. You can probably write all the scores to a file, and then load that file when you start your game again. I'd take a look at sqlite, which is a miniature embedded database designed for this purpose.
Another question. How can i implement a Highscores function in the game? After the ends, it will display along with the current score the previous 5 highest scores? Any resources i can read up or code i can look into?