Jump to content
  • Advertisement


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


C++: displaying floats

This topic is 5604 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, when i use a gcvt function to convert, for example, 0.02 to a char, when i display it i get "3.e-002". How can i print the 0.02 value instead ?

Share this post

Link to post
Share on other sites
thx for your help, i have a printing routine as follows:

GLvoid glPrint_IMG(GLint x, GLint y, char *string, int set) // Where The Printing Happens

glBindTexture(GL_TEXTURE_2D, texture_IMG[0]); // Select Our Font Texture
glPushAttrib(GL_LIST_BIT); // Pushes The Display List Bits
glListBase(base_IMG-32+(128*set)); // Sets The Base Character to 0
glCallLists(strlen(string), GL_BYTE, string); // Draws The Display List Text


so i try to use it like this: glPrint_IMG(0,0,&float_str,0);

But i get the following error:
error C2664: ''glPrint_IMG'' : cannot convert parameter 3 from ''class std::basic_string,class std::allocat
or > *'' to ''char *''
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.

Share this post

Link to post
Share on other sites
yep, it worked using it like this:

const char * szWork = float_str.c_str();

thanks everybody for helping me !

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!