use*_*826 3 c++ string unicode c++builder
我有个问题。我需要将字符串类型转换为 unicode。我知道方法像
string.c_str();
Run Code Online (Sandbox Code Playgroud)
但它在我的代码中不起作用。
我有功能
void modify(string infstring, string* poststring)
Run Code Online (Sandbox Code Playgroud)
在其中我需要在备忘录中显示 infstring。像一个
Form1->Memo1->Lines->Add("some text "+infstring.c_str()+" some text");
Run Code Online (Sandbox Code Playgroud)
但编译器说我“E2085 无效指针添加”
我该如何解决我的问题?
Form1->Memo1->Lines->Add("some text "+infstring.c_str()+" some text");
Run Code Online (Sandbox Code Playgroud)
应该
Form1->Memo1->Lines->Add(("some text "+infstring+" some text").c_str());
Run Code Online (Sandbox Code Playgroud)
即您将字符串文字添加到std::string 然后用于c_str()从中获取 a const char*。
如果Add()函数采用不同的类型,这仍然不起作用,但是您没有提供足够的信息来了解您要询问的内容。