SysUtilsStrEnd (C++)

From RAD Studio 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 edit control's text is copied into a buffer. Then the buffer is displayed backwards in the label.


Code

void __fastcall TForm1::Button1Click(TObject *Sender)
{
  wchar_t* pszEditText = new wchar_t[Edit1->Text.Length()+1];
  wchar_t *psz;
  StrCopy(pszEditText, Edit1->Text.w_str());
  psz = StrEnd(pszEditText);
  Label1->Caption = "";
  while (psz >= &pszEditText[1])
  {
	psz--;
	Label1->Caption = Label1->Caption + *psz;
  }
  delete [] pszEditText;
}

Uses