您的位置:首页 > 其它

异常2error C2664: “sendto”: 不能将参数 2 从“CString”转换为“const char *”

2014-04-02 19:39 423 查看

错误2error C2664: “sendto”: 不能将参数 2 从“CString”转换为“const char *”

VC 6的时候可能没问题,VC2005咋弄?

GetDlgItemText(IDC_EDIT2,strSend);

sendto(m_socket,strSend,strSend.GetLength()+1,0,(SOCKADDR*)&addrTo,sizeof(SOCKADDR));

------解决方案--------------------

sendto(m_socket,(LPCSTR)strSend,strSend.GetLength()+1,0,(SOCKADDR*)&addrTo,sizeof(SOCKADDR));

------解决方案--------------------

类型不同的,一个是cstring,一个是const char*,要进行类型转换

vc2005更标准了

------解决方案--------------------

unicode吧,直接发unicode,然后接收时也按照unicode来处理

sendto(m_socket,(LPCSTR)(LPCTSTR)strSend,strSend.GetLength()*2+2,0,(SOCKADDR*)&addrTo,sizeof(SOCKADDR));

------解决方案--------------------

改变工程设置中不使用UNICODE

Project->Property->Configuration Properties->General->Character set
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐