StrDispose (C++)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This example uses an edit control and a button on a form. When the button is clicked, memory is allocated for a copy of the text in the edit control, the text is displayed in a message box, and then the memory is deallocated.

Code

void __fastcall TForm1::Button1Click(TObject *Sender)
{
  // Allocate memory.
  char* psz = StrNew(Edit1->Text.t_str());
  Application->MessageBox(
	Edit1->Text.c_str(),
	L"StrNew, StrDispose example",
	MB_OK);
  // Deallocate memory.
  StrDispose(psz);
}

Uses