在网上找了三个方法可还是不行,调用有时返回空有时内存出错。
请问有什么好的方法啊?
请问有什么好的方法啊?
解决方案 »
- tvMex.iSelectedImage=1;//为什么TVINSERTSTRUCT不管用没变化!
- 用VC实现对数据库记录集查询
- 背景图片出现“印花”
- 请教关于输出中文
- 关于语音聊天室的问题
- 要崩溃了!关于OnCreate函数!!!
- 基于WSAEventSelect模型,不是很明白其发送的处理逻辑,请高手指教,谢谢!
- 我把listctrl控件的属性设置为ICON,这样的话怎样为该控件添加图标?在先等
- 有关SOCKET的问题,50分我全给了!!急急急!
- 30分:我在菜单里加了一个菜单项,为什么在ClassWizard里面找不到其ID,以前是可以的亚??
- ActiveX控件如何传递Icon句柄?
- CCWGraph::PlotY()该如何调用
sprintf(chs,str);
CString str("134");
sprintf(chs,str);void CDlgcsdn20Dlg::OnButton2()
{
char chs[100];
CString str("134");
//sprintf(chs,str);
strcpy(chs,str);
}技术上可行
符合你的要求吗?
如果不明白,你可以
(1),给我发短消息(请附帖子的地址).
(2),根据http://www.vcshare.net上的联系方式与我联系,推荐QQ.
(3),如果问题简单,请在http://www.vcshare.net/bbs上发帖.
如果问题比较复杂,请把代码压成*.rar当附件发在我的论坛上发帖.
同时在www.csdn.net上发帖,并给出在我的论坛的链接.
---------------
压代码前,请先删除debug,release文件夹,及*.opt,*.ncb,*.plg,*.aps.
char* buf;
char buf1[100];
str = _T("2008北京奥运");
buf = (LPSTR)(LPCTSTR)str;
memset(buf1, 0, sizeof(buf1));
strcpy(buf1, str);
{
/*
*********************************************************************
* 函数说明:将CString型变量转换为unsigned char型——1
* 输 入 值:strValue -> 传入的 CString 值
* istrLength -> CString值的长度
* 输 出 值:转换后的 unsigned char 值
* 编 写 人:
* 创建时间:2004-10-09 pm
*********************************************************************
*/ BYTE *btValue = new BYTE[istrLength];
memcpy((char *)btValue, strValue.GetBuffer(0), istrLength);
strValue.ReleaseBuffer(); return btValue;
}bool CSDTFILE::string2unchar(CString strValue, int istrLength, BYTE *& returnByte)
{
/*
*********************************************************************
* 函数说明:将CString型变量转换为unsigned char型——2
* 输 入 值:strValue -> 传入的 CString 值
* istrLength -> CString值的长度
* 输 出 值:转换后的 unsigned char 值
* 编 写 人:
* 创建时间:2004-10-09 pm
*********************************************************************
*/ returnByte = new BYTE[istrLength+1];
memcpy((char *)returnByte, strValue.GetBuffer(0), istrLength);
strValue.ReleaseBuffer();
returnByte[istrLength] = '\0';
return true;
}希望对你有所帮助
char* send;
send = st.GetBuffer( st.GetLength() );
用完了记得ReleaseBuffer
char szBuffer[200];
memset(szBuffer,0,200);
strcpy(szBuffer,csSrc.GetBuffer(csSrc.GetLength()));这样就可以了.
char ch[100]={0};
1. strcpy(ch,cs);
2. sprintf(ch,cs);
都可以
char buf[200];
::strcpy(buf,str);
char *p;
p=str.GetBuffer(MAX_PATH);
str.ReleaseBuffer();