I'm getting an error where it says I'm trying to use a null pointer. Then when I click ignore another error saying I tried to read or write protected memory. Any idea how to fix?
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
using namespace System::Runtime::InteropServices;
using namespace System;
using namespace System::Text;
System::String ^ zs = textBox1->Text;
char* str2 = (char*)(void*)Marshal::StringToHGlobalAnsi(zs);
bob.SendData(str2);
Sleep(2000);
char er[50];
memcpy(er,"-",50);
bob.RecvData(er,50);
string string1(er, 50);
System::String ^swq;
MarshalString(swq, string1);
label2->Text = "Hi";
}