How can I convert from UInt to CString and back and LPTSTR to CString and back?
Printable View
How can I convert from UInt to CString and back and LPTSTR to CString and back?
nm i think i got it. Though I get an error when I try to use CString:
I have windows.h and string.g included.Code:error C2065: 'CString' : undeclared identifier
error C2146: syntax error : missing ';' before identifier 'str'
error C2065: 'str' : undeclared identifier
from UINT to CString:
CString str;
str.Format("%i", 123);
Is it even possible to use CString in straight win32 API or is it MFC specific?
nope, it's not in Win32 API, you can use it in MFC.
Is there an alternative I can use?
I could use <string> but how can I convert from UINT to string and back?
The STL has a the sstream header.
That doesn't have anything to so with MFC however this code should be useful.Code:
#include <iostream>
#include <sstream>
int main(void) {
using namespace std;
istringstream from;
ostringstream to;
int i;
to << 15;
cout << to.str() << endl;
from = to.str();
from >> i;
cout << i << endl;
return 0;
}