Advertisement

float to char

Started by June 22, 2002 04:21 PM
3 comments, last by HunterTKilla 22 years, 7 months ago
I want to be able to display the float positions of an object on the screen. So far I am doing this:
  
char CameraX[4];
char CameraY[4];
char CameraZ[4];
ZeroMemory(&CameraX, sizeof(CameraX));
ZeroMemory(&CameraY, sizeof(CameraY));
ZeroMemory(&CameraZ, sizeof(CameraZ));
itoa(camera.pos.x, CameraX, 10);
itoa(camera.pos.y, CameraY, 10);
itoa(camera.pos.z, CameraZ, 10);
  
The numbers do not show decimal values, how do I turn floats into chars?? I looked on MSDN and couldn''t find anything, thanks for the help in advance.
Untested solution.
char CameraPosition[80];sprintf(CameraPosition, "%f, %f, %f", camera.pos.x, camera.pos.y, camera.pos.z);  


Update: It works.

Later,
ZE.

//email me.//zealouselixir software.//msdn.//n00biez.//
miscellaneous links


[edited by - zealouselixir on June 22, 2002 6:11:00 PM]

[twitter]warrenm[/twitter]

Advertisement
Thank You
I love quick solutions ^^

Wish all things could be solved like thus ^^ .sen
"I want to make a simple MMORPG first" - Fenryl
Yeah, the trouble is that even a slight increase in problem difficulty greatly reduces the number of people who know the answer, along with the time it takes to solve and the amount of time someone is willing to expend to solve it. Fortunately, this one was rather simple

Later,
ZE.

//email me.//zealouselixir software.//msdn.//n00biez.//
miscellaneous links

[twitter]warrenm[/twitter]

This topic is closed to new replies.

Advertisement