Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Strings  (Read 2912 times)

0 Members and 1 Guest are viewing this topic.

ravenheart

  • Full Member
  • ***
  • Posts: 148
    • View Profile
Strings
« 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 ?

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Strings
« Reply #1 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 ;)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

ravenheart

  • Full Member
  • ***
  • Posts: 148
    • View Profile
Strings
« Reply #2 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?

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Strings
« Reply #3 on: September 15, 2008, 07:33:04 pm »
Yes, that should work. For further information about stringstreams and their methods, see here.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development: