I'm currently working on a new project that I want to have a list of the top 5 high scores but ifstream objects seem to only be able to convert each line into a string.
However to print it to the screen I need it to be a char * so I don't know what to do.
And another more minor problem is that every time the program starts I want the highscores.txt file to be filled with fake scores but ONLY if it's empty, but I can't think of any way to check that.
Any and all help will be very appreciated.
TTF High Scores Dilema
Moderator: PC Supremacists
-
- Chaos Rift Regular
- Posts: 198
- Joined: Thu Mar 26, 2009 8:42 pm
- Current Project: My Engine
- Programming Language of Choice: C++
TTF High Scores Dilema
My first game: http://donsvoice.com/randomdever/Duck%2 ... 01.0.0.zip
My second game: http://donsvoice.com/randomdever/Space%20Invaders.zip
My third game: http://donsvoice.com/randomdever/BreakOut!.zip
My second game: http://donsvoice.com/randomdever/Space%20Invaders.zip
My third game: http://donsvoice.com/randomdever/BreakOut!.zip
Re: TTF High Scores Dilema
Look at the reference. They have a member function called c_str.
-
- Chaos Rift Regular
- Posts: 198
- Joined: Thu Mar 26, 2009 8:42 pm
- Current Project: My Engine
- Programming Language of Choice: C++
Re: TTF High Scores Dilema
Tried that already.
My first game: http://donsvoice.com/randomdever/Duck%2 ... 01.0.0.zip
My second game: http://donsvoice.com/randomdever/Space%20Invaders.zip
My third game: http://donsvoice.com/randomdever/BreakOut!.zip
My second game: http://donsvoice.com/randomdever/Space%20Invaders.zip
My third game: http://donsvoice.com/randomdever/BreakOut!.zip
- Bakkon
- Chaos Rift Junior
- Posts: 384
- Joined: Wed May 20, 2009 2:38 pm
- Programming Language of Choice: C++
- Location: Indiana
Re: TTF High Scores Dilema
Then it should work.RandomDever wrote:Tried that already.
Code: Select all
string myString = "High Score";
TTF_RenderText_Solid(font, myString.c_str(), color);
-
- Chaos Rift Regular
- Posts: 198
- Joined: Thu Mar 26, 2009 8:42 pm
- Current Project: My Engine
- Programming Language of Choice: C++
Re: TTF High Scores Dilema
EDIT: Well I tried it and it works now..... For some reason.
But how do I check whether a text file is empty or not?
And how do you add two strings together with a space added to separate them?
But how do I check whether a text file is empty or not?
And how do you add two strings together with a space added to separate them?
My first game: http://donsvoice.com/randomdever/Duck%2 ... 01.0.0.zip
My second game: http://donsvoice.com/randomdever/Space%20Invaders.zip
My third game: http://donsvoice.com/randomdever/BreakOut!.zip
My second game: http://donsvoice.com/randomdever/Space%20Invaders.zip
My third game: http://donsvoice.com/randomdever/BreakOut!.zip
- Bakkon
- Chaos Rift Junior
- Posts: 384
- Joined: Wed May 20, 2009 2:38 pm
- Programming Language of Choice: C++
- Location: Indiana
Re: TTF High Scores Dilema
Have you tried reading any documentation?
http://www.cplusplus.com/reference/iostream/fstream/
peek() and see if it's empty.
http://www.cplusplus.com/reference/iostream/fstream/
peek() and see if it's empty.
- hurstshifter
- ES Beta Backer
- Posts: 713
- Joined: Mon Jun 08, 2009 8:33 pm
- Favorite Gaming Platforms: SNES
- Programming Language of Choice: C/++
- Location: Boston, MA
- Contact:
Re: TTF High Scores Dilema
Bakkon wrote:Have you tried reading any documentation?
Haha, this
"Time is an illusion. Lunchtime, doubly so."
http://www.thenerdnight.com
http://www.thenerdnight.com