SysUtilsStrIComp (C++)

From RAD Studio Code Examples
Jump to: navigation, search

Description

The following example uses two edit controls and a button on a form. When the button is clicked, the text in the edit controls is compared case-insensitively.

Code

#include <memory>       //For STL auto_ptr class

void __fastcall TForm1::Button1Click(TObject *Sender)
{
  wchar_t *szResult = new wchar_t[Edit1->Text.Length() + Edit2->Text.Length() + 20];
  int iResult = StrIComp(Edit1->Text.c_str(), Edit2->Text.c_str());

  StrCopy(szResult, Edit1->Text.c_str());
  if (iResult < 0)
	StrCat(szResult, L" is less than ");
  else if (iResult > 0)
	StrCat(szResult, L" is greater than ");
  else
	StrCat(szResult, L" is equal to ");
  StrCat(szResult, Edit2->Text.c_str());
  ShowMessage(szResult);
  delete [] szResult;
}

Uses