Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Converting float to strings

This topic is 6929 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi everybody! I want a fps-counter in my game(for testing purposes) and I want the fps to appear on my screen. I use the TextOut function but cannot convert the fps(in float) to a string that TextOut can work with! How can I convert this sucking fps? (I don''t use the MFC! So no CString-blabla..)

Share this post

Link to post
Share on other sites
Use sprintf... the difference between printf and sprintf is that sprintf doesn't output to the screen. It creates a string that holds what would have been outputted to the screen. The following command will do the trick you want.

#include <stdio.h>

char string[20];
float floatvar;



Edited by - Torval on 5/6/00 7:32:43 AM

Edited by - Torval on 5/6/00 7:34:57 AM

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!