![]() |
|
How do i print numbers |
DuncanShine
Member #17,479
March 2020
|
I'm trying to use al_draw_text but it wont work with numbers and i'm not sure how to convert to const char* |
torhu
Member #2,727
September 2002
![]() |
DuncanShine
Member #17,479
March 2020
|
that didnt make a difference it's still asking for a const char |
torhu
Member #2,727
September 2002
![]() |
The const char pointer is the format string, the values are added as extra arguments after that. Look at the examples here: |
jmasterx
Member #11,410
October 2009
|
http://www.cplusplus.com/reference/cstdlib/itoa/ if using c++, http://www.cplusplus.com/reference/sstream/stringstream/ Agui GUI API -> https://github.com/jmasterx/Agui |
DuncanShine
Member #17,479
March 2020
|
but what does stringstream actually do? it doesnt seem to convert to const char* |
jmasterx
Member #11,410
October 2009
|
It works just like std cout it will output a std string which you can do .c_str() to get a const char* you can << whaterver you want. Like std::stringstream ss; ss << "I ate" << 22 << "Hot Dogs"; al_draw_text(ss.str().c_str());
Agui GUI API -> https://github.com/jmasterx/Agui |
torhu
Member #2,727
September 2002
![]() |
Drawing an int would look like this: al_draw_textf(my_font, my_color, x_pos, y_pos, 0, "Here it is: %d", my_value); Or replace %d with %f to draw a float or double, etc. |
|