I have looked all over the internet and tried every thing I could; I can not figure out how to convert System::String to the normal std::string.
Here is my code so far:
1 2 3 4 5 6 7 8 9
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
string saved;
string setsave;
fstream text;
struct stat buf;
if (stat(saved.c_str(), &buf) == -1){
this->richTextBox2->Text = "The file could not be made.\nMake sure you did not use / \ : * ? \" < > | in the file name. ";
}
}
For anyone who has the same question here is a sample:
1 2 3 4 5 6
pin_ptr<constwchar_t> p = PtrToStringChars(this->textBox1->Text); //Changes text box text to wchar_t
wstring s(p); //Changes p to wstring
string ss( s.begin(), s.end() ); //changes s to normal string
char *sss = (char*)ss.c_str(); //changes ss to char
System::String^ bbb = gcnew System::String(sss); //changes sss to System::String
this->button3->Text = bbb; //shows the entered text (from textBox1) in button3.
That works fine, but I still need a string and I have no idea how to to convert it. I have tried many different things. By the way what include file do I use to use CString?
Okay. Thank you. I think I can handle it from here.
For anyone who has the same question here is a sample:
1 2 3 4 5 6
pin_ptr<constwchar_t> p = PtrToStringChars(this->textBox1->Text); //Changes text box text to wchar_t
wstring s(p); //Changes p to wstring
string ss( s.begin(), s.end() ); //changes s to normal string
char *sss = (char*)ss.c_str(); //changes ss to char
System::String^ bbb = gcnew System::String(sss); //changes sss to System::String
this->button3->Text = bbb; //shows the entered text (from textBox1) in button3.