还是没有找到接受“char *”类型的右操作数的运算

scanf("%s",this->txt_cfile_par->Text);
String^ temp = this->txt_cfile_par->Text;
void MarshalString ( String ^ s, string& os )
{
using namespace Runtime::InteropServices;
const char* chars = 
(const char*)(Marshal::StringToHGlobalAnsi(s)).ToPointer();
os = chars;
Marshal::FreeHGlobal(IntPtr((void*)chars));
}
strncpy(cfile_par,temp.c_str(),c_str.length());
System::Windows::Forms::MessageBox::Show(temp);
error C2601: “MarshalString”: 本地函数定义是非法的
error C2228: “.c_str”的左边必须有类/结构/联合
error C2228: “.length”的左边必须有类/结构/联合
error C2679: 二进制“+”: 没有找到接受“char *”类型的右操作数的运算符(或没有可接受的转换)

一只甜甜圈
浏览 65回答 1
1回答

冉冉说

我怎么觉得你连最基本的编程概念都没入门呢.......你这好像是C#的代码函数是不能嵌套的吧,C#应该也是不能在一个函数内部定义一个函数(虽然我C#没那么熟)strncpy(cfile_par,temp.c_str(),c_str.length());改成strncpy(cfile_par,temp.c_str(), temp.c_str.length());
打开App,查看更多内容
随时随地看视频慕课网APP