//Form1.h (Windows Forms Application)
//....
//....
#pragma endregion
cli::array <String^> ^sum;
private: System::Void BtnComp_Click(System::Object^ sender, System::EventArgs^ e) {
nocarrystate n;
carrystate c;
char a;
states * curstate;
states::init(&n, &c);
String ^text1 = TxtBin1->Text;
String ^text2 = TxtBin2->Text;
curstate = &n;
int i = 0;
int len1 = text1->Length;
sum = gcnew cli::array <String^>(len1);
while (i < len1)
{
curstate = curstate->next (text1[i], text2[i], a); /// a is passed by reference
sum[i] = a.ToString();
i++;
}
TxtSum->Text = sum.ToString();
}
};
}
My main point of interest is in and after the while loop. 'Variable a' is passed by reference to the next function, and I want to store the value of a in sum then display sum in a text box after the While loop is done. There are several problems I ran into:
-sum = a.ToString(); saves each char's astii code into sum, when I need the actual character. I've tried to test this by having 'variable a' displayed during each iteration of the while loop ( using this line: TxtSum->Text = a.ToString(); ), and the astii is indeed displayed.
-TxtSum->Text = sum.ToString(); displays this: System.String[]
I'd rather use a char array of 'len1' length, but I am unable to do so without several compiler errors.
Help would be greatly appreciated.