sstream and LPSTR
I need to convert a str value from a sstream to LPSTR but I have no clue how.
Hers my code:
The error says:
float currenttime = (float)GetTickCount();
float deltatime = currenttime - lasttime * 0.001f;
outs << deltatime;
LPSTR test = outs.str(); //Error line
error C2440: 'initializing' : cannot convert from 'std::basic_ostringstream<_Elem,_Traits,_Alloc>::_ Mystr' to 'LPSTR'
a couple ways to solve your problem - neither use LPSTR
std::string test = outs.str();
str().c_str() will return a const char*, which is what LPCSTR is. This is different than LPSTR, which is just a char*.
In this case it should be ok, since SetWindowText actually takes an LPCTSTR (which is just an LPCSTR for your program if you don't use Unicode).