CString & char*
CString str
Edit->GetLines(2, (char*) str);
In compliling, the convertion error, then how to convert CString to char*
问题点数:5、回复次数:16Top
1 楼rocmeteor(拄杖携残醉,扶风上九霄)回复于 2001-11-13 14:43:35 得分 1
strcpy
lstrcpy
Top
2 楼jiangping_zhu(娜可露露之风之刃)回复于 2001-11-13 14:46:24 得分 1
(char*)(LPCTSTR)strTop
3 楼jason802(小糊涂仙)回复于 2001-11-13 14:49:53 得分 1
jiangping_zhu 说对了,或者:
char * p = str.GetBuffer(str.GetLength());Top
4 楼caigzhi(George Cai)回复于 2001-11-13 14:51:12 得分 1
CString str;
char temp[256];
Edit->GetLines(2, temp);
str.Format("%s",temp);Top
5 楼code_cold(橘右京傲战八方)回复于 2001-11-13 14:52:38 得分 0
Everyone +2
jason802 +3Top
6 楼ithero(我容易么我)回复于 2001-11-13 14:52:54 得分 1
from char* to CString u can directly use!
but in contast using strcpy();
from string to char* using c_str;
Top
7 楼code_cold(橘右京傲战八方)回复于 2001-11-13 14:57:27 得分 0
the (char*) (LPCTSTR) str is wrong,
when execute, str is null
Top
8 楼code_cold(橘右京傲战八方)回复于 2001-11-13 14:58:43 得分 0
to ithero: say it in detail Top
9 楼code_cold(橘右京傲战八方)回复于 2001-11-13 15:04:08 得分 0
CString str;
char temp[256];
Edit->GetLines(2, temp);
str.Format("%s",temp);
when use the upper, the CString str's length is 256,So when display this string,
it followed many unuseful char, I hope the str's length is the Edit's text length
Who can make itTop
10 楼wwtmw(剑重无锋 大巧不工)回复于 2001-11-13 15:13:10 得分 0
workTop
11 楼anywn_cwh(我有个问题)回复于 2001-11-13 15:14:28 得分 0
char *p = (char *)malloc(sizeof(char)*str.GetLength());
sprintf(p,str);Top
12 楼code_cold(橘右京傲战八方)回复于 2001-11-13 15:36:58 得分 0
Only want to use one variables, CString str
the upper looks too fearTop
13 楼sungang()回复于 2001-11-13 15:41:27 得分 0
只能通过char*过度。不能直接将CString转换为char*
欢迎下载我们的软件:
http://www.csdn.net/cnshare/soft/4/4632.htmlTop
14 楼yhou31(爱谁是谁)回复于 2001-11-13 15:49:31 得分 0
我这个绝对可以的,我经常这么做:
把CString类型的值转换成char*类型的值:
char* szName;
CString temp;
szName = (char*)(LPCTSTR)temp;
把char*类型的值转换成CString类型的值:
temp = szName;
Top
15 楼code_cold(橘右京傲战八方)回复于 2001-11-13 15:51:38 得分 0
Who is us
Corporation or person
Top
16 楼code_cold(橘右京傲战八方)回复于 2001-11-13 15:59:35 得分 0
You can try, the Edit is a control
str is null
Top




