I'm trying to concat "(" + mouseX + ", " + mouseY ")". However, mouseX and mouseY are ints, so I tried using a stringstream as follows:
std::stringstream pos;
pos << "(" << mouseX << ", " << mouseY << ")";
_glutBitmapString(GLUT_BITMAP_HELVETICA_12, pos.str());
And it doesn't seem to work.
I get the following error:
mouse.cpp:75: error: cannot convert
std::basic_string<char, std::char_traits<char>, std::allocator<char> >' to
const char*' for argument2' to
void _glutBitmapString(void*, const char*)'
What am I doing wrong in this basic string + integer concatenation?
glutBitmapString()
expects a char*
and you're sending it a string. use .c_str() on the string like so:
_glutBitmapString(GLUT_BITMAP_HELVETICA_12, pos.str().c_str());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With