Do you know about it ? And is it easy?
When i had a project some months ago, i had to use it but i didn't know and i felt that it was really difficult. But now i feel it is easy because i found one of the best way to do it.
For saving your time, i am introducing now.
+ Convert CString to char*
CString myCString = "I love Viet Nam"; // using: L"I love Viet Nam" if you want to do with Unicode format
char myChar[1000]; // the number depends on your CString's length
//initialize your storage buffer
memset(myChar,0,sizeof(myChar));
sprintf(myChar,"%S",myCString);
Actually, you can use an easier syntax if you don't use Unicode format
myChar = myCString.GetBuffer(myCString.GetLength());
+ Convert char* to CString
CString myCString;
char* myChar = "I love Viet Nam"; // You mustn't insert 'L' before this quote although you can use Unicode format
for(int i = 0; myChar[i] != NULL; i++)
{
myCString += myChar[i];
}Maybe there are many ways to convert this type but i think this is an easy way that you can use.
Best wishes for you!, Thanks for visiting my blog!
Do your best, the rest will come!
Không có nhận xét nào:
Đăng nhận xét