Simple C++ Question
Gosh I can''t believe I forgot the syntax for how to do this in C++. Anyway, to my question. I have a Player''s health that I want to print to the screen that is an int. However, my function for drawing GDI text only takes char*. How the heck would I convert this or whatever so I could print the number? Would I use sprintf, strcat, or what? Thanks for any replies in advance.
Easiest way would be wsprintf (seeing as you almost certainly have windows.h included)
char Health[4]; // Guessing max_health will be <999
wsprintf("%lu/0", Player.Health);
This assumes Player.Health is an unsigned long representing the players health. At the end Health will be a null terminated string containing your players health.
HTH
Steven Vallis
char Health[4]; // Guessing max_health will be <999
wsprintf("%lu/0", Player.Health);
This assumes Player.Health is an unsigned long representing the players health. At the end Health will be a null terminated string containing your players health.
HTH
Steven Vallis
Or just for kicks for non ansi windows only code try integer to alpha like so:
itoa(const char* buffer, uint num, uint base)
char mystring[10] = "";
so itoa(mystring, 122, 10);
base 10 == decimal
base 2 == binary
base 16 == hexidecimal
itoa(const char* buffer, uint num, uint base)
char mystring[10] = "";
so itoa(mystring, 122, 10);
base 10 == decimal
base 2 == binary
base 16 == hexidecimal
Ok, so
lu = unsigned long
d = dword
...
Is there an internet-page with the full list?
Drago
lu = unsigned long
d = dword
...
Is there an internet-page with the full list?
Drago
osu!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement