SFML community forums

Help => Graphics => Topic started by: ravenheart on September 15, 2008, 01:13:15 pm

Title: Strings
Post by: ravenheart on September 15, 2008, 01:13:15 pm
hello  i got an answer for this already in another topic but i couldnt handle it:

i have a game, and now i want to display the time it works,

getting the time is no problem nor generating the Text;
but how can i convert the float into a sf::String ?
Title: Re: Strings
Post by: Nexus on September 15, 2008, 01:35:12 pm
Quote from: "ravenheart"
but how can i convert the float into a sf::String ?
That is not part of the SFML library.

Just use the C++ class std::stringstream ;)
Title: Strings
Post by: ravenheart on September 15, 2008, 01:46:42 pm
just tell me how to do it plz, i dont criticize sfml ^^

does somethin like

Code: [Select]

std::ostringstream out;
out << 3.1415926f;
std::string str(out.str());


work?
Title: Strings
Post by: Nexus on September 15, 2008, 07:33:04 pm
Yes, that should work. For further information about stringstreams and their methods, see here (http://www.cplusplus.com/reference/iostream/stringstream/).