czwartek, 12 września 2019

Reverse text file (Visual C++)



private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {

String^ all_Text="";
String^ my_test_File="C:\\Windows\\setupact.log";
String^ text_File;
StreamReader^ main_File=gcnew StreamReader(my_test_File,System::Text::Encoding::Default);
while(text_File=main_File->ReadLine())
{
all_Text+=text_File;
textBox1->AppendText(text_File+System::Environment::NewLine);
}
main_File->Close();
 
int width_Text=all_Text->Length;
array<System::Char>^ temp_Char1=gcnew array<System::Char>(width_Text);
array<System::Char>^ temp_Char2=gcnew array<System::Char>(width_Text);
int i,j;
for(i=0;i<width_Text;i++)
{
temp_Char1[i]=(Char)all_Text[i];

}
for(i=0,j=width_Text-1;i<width_Text;i++,j--)
{
temp_Char2[i]=temp_Char1[j];
}
String^ reverse_Text=gcnew String(temp_Char2);
textBox2->AppendText(reverse_Text);
 
 


}
private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {
Close();
}
private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
label1->Text="C:\\Windows\\setupact.log";
label2->Text="Reverse text";
}
};
}


Brak komentarzy:

Prześlij komentarz