#include "stdio.h"
#include <string>
#include "Afx.h"
#include <iostream>
using namespace std;
main()
{    CString ch1("abc");
string a("<12 11 34 ><23 ><14 11 >");
ch1=a.data();
std::cout<<a<<"\n";
}

解决方案 »

  1.   

    a.data()返回值是什么类型?
    CString你可以使用吗?
      

  2.   

    a.data()返回的是char* 类型,是一个字符串
    加#include "Afx.h",不会报CString的错。
    但是出了一堆不懂的错误。我现在是想把sting 类型的赋值给CString 类型的变量
      

  3.   

    ch1=a.data();
    改为:ch1.GetBuffer(20)=a.data();试试
    ch1.ReleaseBuffer(20);
      

  4.   

    错误如下,多谢关注
    --------------------Configuration: tr1 - Win32 Debug--------------------
    Compiling...
    tr.cpp
    E:\test\tr1\tr.cpp(13) : warning C4508: 'main' : function should return a value; 'void' return type assumed
    Linking...
    nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in libcpd.lib(delop.obj)
    nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
    nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
    Debug/tr1.exe : fatal error LNK1120: 2 unresolved externals
    Error executing link.exe.tr1.exe - 4 error(s), 1 warning(s)
      

  5.   

    可是,不能运行呀。我的MSN  [email protected].在线等待
    怎样才可以把sting 赋值给CString 类型的变量呢?
      

  6.   

    多帖点代码出来,主要是data的!看看
      

  7.   

    :(   data 是string 的成员函数啊