Jump to content
  • Advertisement

Archived

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

pan narrans

Data Conversion - aaaargh!

This topic is 5859 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

I have a value (long FPS) that I need to pass to a PrintToScreen function that accepts char * (PrintToScreen(char *)). Unfortunately, I''m rubbish at converting data values and the VC++ help files are hard to navigate if you don''t know exactly what you are looking for. I tried passing (char*)&FPS but the result was gibberish. I suspect this is because I am converting the type but not the actual data stored in memory. For instance, if FPS is 30, I need the char value to be "30". I know the answer will probably be simplistic but I would appreciate any help. Cheers, pan narrans

Share this post


Link to post
Share on other sites
Advertisement
You need to convert your long into a string (array of characters).

This can be done using sprintf or itoa, which you should be able to type in, highlight, and press F1 to get help on.


Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions

Share this post


Link to post
Share on other sites
I knew it would be simple:

char buffer[3];
_itoa( FPS, buffer, 10 );
PrintToScreen( buffer );

Just posted the solution in case anyone ever searches for it

Thanx siaspete

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!