How do I convert char * To lpctstr ??
Rainforestbache (BaiQi) 20:17:48 in VC/mfc/basic
Please kindly advise
Number of questions: 20. replies: 10
1 floor, Stephen _young (), with a score of 5 at 20:33:45
Convert char * To A cstring object.
Char * P = "aaaa ";
Cstring S = P; // or
Cstring M (P );
Maid Lp = (maid) s; // maid Lp = (maid) m;
You can use either of these two statements.
Top
Rainforestbache (BaiQi) on the second floor replied to 20:34:34 score 0
Is there any other way to use cstring?
Top
Fanqing (Naruto + 28% (preparation process/thread) on the third floor) Replies to 20:34:46 score 5
Cstring dd = "fanqing ";
Dd. getbuffet (10 );
Top
Bestbear (tianwaifei Xiong) on the 4 th floor replied to-10-19 20:37:28 score 5
1> convert char * To cstring
If char * is converted to cstring, you can use cstring: format in addition to direct value assignment. For example:
Char charray [] = "this is a test ";
Char * P = "this is a test ";
Or
Lpstr P = "this is a test ";
Or in the use of Unicode applications that have been defined
Tchar * P = _ T ("this is a test ");
Or
Lptstr P = _ T ("this is a test ");
Cstring thestring = charray;
Thestring. Format (_ T ("% s"), charray );
Thestring = P;
2> cstring to lpctstr
Lptstr lptext;
Cstring STR;
Str. Format ("% d", );
Lptext = (lpctstr) STR;
Top
Rainforestbache (BaiQi) on the fifth floor replied to 20:41:38 score 0
Thank you very much for all of the above, such as Stephen Young (), fanqing (yufan), and bestbear (yufei Xiong)
But the younger brother doesn't want to use the cstring class library. Is there any other way?
Top
Rainforestbache (BaiQi) on the 6th floor replied to 20:49:41, score 0
I want to develop a wince network program using APIs and socket2 functions,
Char hostname [100];
Int Len;
Len = 100;
Memset (& hostname [0], \ 0, 100 );
If (gethostname (& hostname [0], Len) = 0 ){
Setwindowtext (getdlgitem (g_hwndmydialog, idc_edit1), & (hostname [0]);
}
Else {
Setwindowtext (getdlgitem (g_hwndmydialog, idc_edit1), _ T ("error "));
Break;
}
The above program must use char * For gethostname, while setwindowstext uses lpctstr for conversion.
Top
On the 7th floor, huwei001982 (programming prodigal son) replied to 20:54:52 score 5
Ah
Char * P = "dfkdslf"
Lpctstr d = (lpctstr) P;
No?
Top
On the eighth floor, huwei001982 (programming prodigal son) replied to 20:55:55, with a score of 0
Correct the upstairs. char * P = "dfkdslf"; // a semicolon is dropped;
Top
9 Floor rainforestbache (BaiQi) reply to 21:09:32 score 0
Huwei001982 (programming prodigal)
Char * P = "dfkdslf"
Lpctstr d = (lpctstr) P;
This is not the case. The lpctstr is actually unsigned short *, in the unit of 2 bytes, And the char * is in the unit of 1 byte.
Top
Rainforestbache (BaiQi) on the 10th floor replied to 21:36:08 score 0
Thank you for solving the problem. In the end, you can only use the dumbest solution.
Bool lpcstr2lptstr (lpcstr STR, lptstr wstr)
{
Int L, I;
L = strlen (STR );
For (I = 0; I <= L; I ++) wstr [I] = STR [I];
Return true;
};
If you have a better solution, please send me a message.
Thank you again.