strcpy”: 不能将参数 2 从“CString”转换为“const char *”
我做的是  strcpy(title,m_sztitle);    参数1 title声明如下 :char title[100] 
                            参数2 m_sztitle 声明如下: CString m_sztitle;
为什么会出错啊

解决方案 »

  1.   

         错误很明显啊,参数类型不对。strcpy的原型是strcpy(char *,const char *);
      

  2.   

    strcpy默认都是字符串类型char*的而不是string, cstring...
      

  3.   

    是否为unicode工程呢?如果是,试试
    TCHAR title[100];
    _tcscpy(title,m_sztitle); 
      

  4.   

    改成
    strcpy(title,m_sztitle.GetBuffer(m_sztitle.GetLength()));    
      

  5.   

    //strcpy(title,m_sztitle);    
    strcpy(title, m_sztitle.GetBuffer(0));
    m_sztitle.ReleaseBuffer();
    //以下也行
    strcpy(title, (LPSTR)(LPCSTR)m_sztitle);//最好判断下m_sztitle.GetLength()是否 >= 100
      

  6.   

    strcpy(title,m_sztitle.GetBuffer(0));