/*
StrLComp example
The following example uses two edit controls and a button on a form. When the button is clicked, the first X bytes of the edit controls are compared, where X is the number of characters in the shorter string.
*/ 
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  char* szResult = new char[Edit1->Text.Length() + Edit2->Text.Length() + 65];
  char* Edit1Text = Edit1->Text.c_str();
  char* Edit2Text = Edit2->Text.c_str();
// the following 2 lines are for CLX applications
// char* Edit1Text = WideCharToString(Edit1->Text.c_bstr()).c_str();
// char* Edit2Text = WideCharToString(Edit2->Text.c_bstr()).c_str();
  int len = min(Edit1->Text.Length(), Edit2->Text.Length());
  int iResult = StrLComp(Edit1Text, Edit2Text, len);

  StrCopy(szResult, "The first ");
  StrCat(szResult, IntToStr(len).c_str());
  StrCat(szResult, " bytes of ")
  StrCat(szResult, Edit1Text);
  if (iResult < 0)
    StrCat(szResult, " are less than the first ");
  else if (iResult > 0)
    StrCat(szResult, " are greater than the first ");
  else
    StrCat(szResult, " are equal to the first ");
  StrCat(szResult, IntToStr(len).c_str());
  StrCat(szResult, " bytes of ");
  StrCat(szResult, Edit2Text);

  ShowMessage(szResult);
  delete [] szResult;
}; 
