humm... how do you convert an int to CString?
Printable View
humm... how do you convert an int to CString?
If you are not using unicode the base character for CString.
is TCHAR, which is based on char.
You can cast TCHAR from char:
Code:TCHAR *v;
int i
char test[20];
sprintf(test,"%d",i);
v= (TCHAR) test;
hi Jim.... How can I put the vaue of and int var to for exampe to a CString var?
OR.. how can I display the value of an int var in the MessageBox of VC++?
Thank you for heping me
Try this:
PHP Code:#include <iostream>
#include <cstdlib>
using namespace std;
#include <windows.h>
int main()
{
int nInput;
char szText[20];
cout << "Enter a number: ";
cin >> nInput;
sprintf(szText, "%d", nInput);
MessageBox(NULL, szText, "Test", MB_OK);
return 0;
}
CString str;
str.Format("Any control string %i you want.", 123);
TRACE("%s", (LPCTSTR)str);
will output:
Any control string 123 you want.
thank you :) thats exactly what i needed :)