CString str,temp;
c_edit.GetWindowTextW(str);
if (str.IsEmpty())
return;
temp.Format(_T("a说: %s"),str);
c_list.AddString(temp);
int num =send(serversocket,temp.GetBuffer(temp.GetLength()),temp.GetLength(),0);
c_edit.SetWindowText(_T(""));1>d:\backup\我的文档\visual studio 2008\projects\client\client\clientdlg.cpp(208) : error C2664: “send”: 不能将参数 2 从“wchar_t *”转换为“const char *”
这个错误要怎么改啊

解决方案 »

  1.   

    int num =send(serversocket,temp.(char*)GetBuffer(temp.GetLength()),temp.GetLength(),0); 
    试试。
      

  2.   

    晕,错了。
    int num =send(serversocket,(char*)temp.GetBuffer(temp.GetLength()),temp.GetLength(),0); 
      

  3.   


    我改成这样以后 
    int num =send(serversocket,(LPSTR)(LPTSTR)temp.GetBuffer(temp.GetLength()),temp.GetLength(),0);
    错误没了, 不过传过去的是乱码
      

  4.   

    你接收的工程最好也是UNICODE的
      

  5.   

    CString temp;
    temp.GetBuffer(temp.GetLength())返回类型不是const char *吗?
    怎么会出错
      

  6.   


    有两个问题
    1. 这里不需要GetBuffer,你为什么要GetBuffer
    2. 发送方和接收方的编码方式必须相同(这里肯定是unicode宽字符方式的),否则你需要自己进行编码转换
      

  7.   

    发送端 WideCharToMultiByte 接收端 MultiByteToWideChar
      

  8.   

    我觉得也是啊,不过它就是报错啊
    yschenwei  你这样改和我的应该差不多吧
      

  9.   

    按原理来说,无论什么类型的数据最后都必须以char*才能被发送。
    就算是结构体都可以,wchar_t 其实是unsigned short 怎么会不行呢?
    除非是向上面几位说的,你接收方用的是别的字符集。