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

Author Topic: Print ints  (Read 918 times)

0 Members and 1 Guest are viewing this topic.

symtaxiz

  • Newbie
  • *
  • Posts: 9
    • View Profile
Print ints
« on: January 06, 2014, 02:15:36 pm »
Hi people of this community  :),
Can you please tell me if it is possible to print an int in a text? Because as I know it is only possible to print a string (sf::String). I want to do this because I'd like to show how much points the player have in a very simple game.
Thank you for the attention.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10997
    • View Profile
    • development blog
    • Email
Re: Print ints
« Reply #1 on: January 06, 2014, 02:27:16 pm »
"print" is probably not the best description, but I assume you want to draw an sf::Text and use an integer as value.

If you have a C++11 compatible compiler, you can use std::to_string otherwise, you can use a std::stringstream. The conversion between std::string and sf::String can then happen rather easily.

If you still don't get how to do it, I suggest you google "int to string c++" and you'll find tons of solutions. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

symtaxiz

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Print ints
« Reply #2 on: January 06, 2014, 03:26:48 pm »
Thank you!!! ;D
I have solved it.

 

anything