SysUtilsStrPCopy (C++)

From Appmethod Code Examples
Jump to: navigation, search

Description

The following example uses an edit control, a label, and a button on a form. When the button is clicked, the label's caption and the edit control's text are combined in a buffer. Then the buffer is displayed in the label's caption.

Code

void __fastcall TForm1::Button1Click(TObject *Sender)
{
  wchar_t* szBuffer = new wchar_t[Label1->Caption.Length() + Edit1->Text.Length() + 1];
  StrPCopy(szBuffer, Label1->Caption);
  StrCat(szBuffer, Edit1->Text.c_str());
  Label1->Caption = szBuffer;
  Edit1->Clear();
  delete [] szBuffer;
}

Uses