CopyMemory(sendBuf+m_SendStr.GetLength(),&m_SendNum,4);

cxxlp 2010-09-15 07:17:16
新手问题



CopyMemory(sendBuf+m_SendStr.GetLength(),&m_SendNum,4);



我的sendstr 如果长度输入超过 6个字符时,程序就自动退出了,请问是什么原因,如何修改.
...全文
57 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
91program 2010-09-16
  • 打赏
  • 举报
回复
这种问题,调试看看地址一般都能解决的.

退出,无非是操作了不应该操作的地址.
chinesedragon2010 2010-09-16
  • 打赏
  • 举报
回复
CopyMemory(sendBuf+m_SendStr.GetLength(),&m_SendNum,4);
--->我觉得楼主上面第一个参数很奇怪,为什么是sendBuf+m_SendStr.GetLength(),而不是sendBuf,而且第二个参数m_SendNum为什么是int的,而不是和sendBuf = new char(sendLen)一样来申请的,很奇怪啊,下面是百度百科的用法,希望对楼主有帮助
char szname[50]="阵雨";   
char szfriend[]="polelf,oo";   
CopyMemory(szname+4,szfriend,10);  
OutputDebugString(szname);//输出结果为"阵雨polelf,oo"
cxxlp 2010-09-15
  • 打赏
  • 举报
回复
char * sendBuf;
int sendLen=0;
int m_SendNum = 0;

CString m_SendStr = "";

this->m_cordernumber.GetWindowText(m_SendStr);

sendLen = m_SendStr.GetLength()+4;
sendBuf = new char(sendLen);
WideCharToMultiByte(CP_ACP,WC_COMPOSITECHECK,m_SendStr.GetBuffer(m_SendStr.GetLength())
,m_SendStr.GetLength(),sendBuf,m_SendStr.GetLength(),NULL,NULL);


CopyMemory(sendBuf+m_SendStr.GetLength(),&m_SendNum,4);
winceARM 2010-09-15
  • 打赏
  • 举报
回复
这个问题太笼统啦,都不知道你的sendBuf是怎么定义的,怎么去回答呢?是不是越界了呢?

19,502

社区成员

发帖
与我相关
我的任务
社区描述
硬件/嵌入开发 嵌入开发(WinCE)
社区管理员
  • 嵌入开发(WinCE)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧