Reputation: 13
I'm trying to get my Frames-Per-Second readout to appear in my window title. I have done it once before, but how would I set up the code to do that? I need to switch from float to const char *.
Upvotes: 1
Views: 1293
Reputation: 1049
A simple way to do, and making it compatible with every numerical could be that:
#include <sstream>
template<class T>
char* toChar(T t) {
std::ostringstream oss;
oss << t;
return oss.str().c_str();
}
This way, no matter if you use int, float, long or whatever else, it will work and return it as a char* string.
Upvotes: 2