텍스트 상자의 내용을 .txt 파일 인 의 텍스트로 설정하려고합니다. 그러나 제대로 작동하지 않습니다. 프로그램을 컴파일 할 때 나는이 두 오류를 얻을(C++/CLI) 텍스트 상자의 내용을 .txt 내용으로 설정합니다.
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
std::ifstream dat1("DataStore.txt");
String^ textHolder;
if (dat1.is_open())
{
while (getline(dat1, line))
{
textHolder += line.c_str;
}
textBox1->Text = textHolder;
dat1.close();
}
else textBox1->Text = "Unable to open file";
}
:
내가 .txt 파일의 그것과 텍스트 상자의 내용을 "새로 고침"것 버튼이, 여기 내가 사용하고있는 코드입니다error C3867: 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>::c_str': function call missing argument list; use '&std::basic_string<char,std::char_traits<char>,std::allocator<char>>::c_str' to create a pointer to member
error C2297: '+=' : illegal, right operand has type 'const char *(__thiscall std::basic_string<char,std::char_traits<char>,std::allocator<char>>::*)(void) throw() const'
어떻게하면됩니까?
참고 : 나는
실제 C++ 코드를 작성하는 것은 어떻습니까? "String ^"은 C++가 아닙니다. Microsoft의 표준 C++ 언어 변이입니다. –
이것은 C++도 Windows API를 호출하지도 않습니다. C++/CLI를 사용하는 경우 적절한 태그를 사용하십시오. 이것이 .NET을 목표로한다면 적절한 태그를 사용하십시오. 그리고 그렇지 않은 사람들은 제거하십시오. (놀랍게도, 요즘 개발자들은 더 이상 사용하고있는 프로그래밍 언어 나 타겟 플랫폼조차 모르고 있습니다. [Visual Studio는 마음을 열었습니까?] (http://charlespetzold.com/etc/DoesVisualStudioRotTheMind.html) 그것.) – IInspectable
글쎄, "String ^"대신 "String ^"을 사용할 때마다 "System :: String 클래스에 기본 생성자가 없습니다"라는 오류 메시지가 나타납니다. –