string content = data["content"].asString();
CString strText(content.c_str());
strText = content.c_str;
strText.format("%s", content.c_str());
我想把content转换为Cstring的形式,请问有什么方法吗?
Format应该是大写,C++是大小写敏感的。
你的data["content"]数组是个map?
我直接传了个字符串进去,里面包含了你的3种赋值方式,可以正常运行,程序如下:
#include <iostream>
#include <afxwin.h>
using namespace std;
int main()
{
string content = "TestString";
CString strText1(content.c_str());
CString strText2 = content.c_str();
CString strText3;
strText3.Format("%s", content.c_str());
cout << "strText1:" << strText1 << endl;
cout << "strText2:" << strText2 << endl;
cout << "strText3:" << strText3 << endl;
}
可以正常输出,注意工程属性要选使用“多字节字符集”
不知道你这个问题是否已经解决, 如果还没有解决的话: