|
-
Mar 31st, 2002, 12:44 PM
#1
Thread Starter
Fanatic Member
Type Conversion (very easy)
humm... how do you convert an int to CString?
"The difference between mad and genius is the success"
-
Mar 31st, 2002, 04:51 PM
#2
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;
-
Apr 1st, 2002, 08:55 PM
#3
Thread Starter
Fanatic Member
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
"The difference between mad and genius is the success"
-
Apr 1st, 2002, 09:08 PM
#4
Fanatic Member
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;
}
Alcohol & calculus don't mix.
Never drink & derive.
-
Apr 2nd, 2002, 01:52 PM
#5
CString str;
str.Format("Any control string %i you want.", 123);
TRACE("%s", (LPCTSTR)str);
will output:
Any control string 123 you want.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Apr 3rd, 2002, 09:16 PM
#6
Thread Starter
Fanatic Member
thank you thats exactly what i needed
"The difference between mad and genius is the success"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|