Copies null-terminated string.
function StrECopy(Dest: PChar; const Source: PChar): PChar;
const char * StrECopy(const char * Dest, const const char * Source);
SysUtils
StrECopy copies Source to Dest and returns StrEnd(Dest).
StrECopy does not perform any length checking. The destination buffer must have room for at least StrLen(Source)+1 characters.
Nested calls to StrECopy to concatenate a sequence of strings run more efficiently than multiple calls to StrCat.
C++ Examples:
/* 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 appended to a static buffer. Then the buffer is displayed in the label’s caption. */ const static int MAX_LENGTH = 15; void __fastcall TForm1::Button1Click(TObject *Sender) { static char szBuffer[MAX_LENGTH]; static char* pszBuffer = szBuffer; if (StrLen(pszBuffer) + StrLen(Edit1->Text.c_str()) < MAX_LENGTH) pszBuffer = StrECopy(pszBuffer, Edit1->Text.c_str()); else ShowMessage("Can't fit new string in allocated memory space."); Label1->Caption = szBuffer; }
Delphi Examples:
{ This example uses a button on a form. Since StrECopy returns the destination char array, nested calls are possible and actually more efficient than repeated calls. StrECopy does no bounds checking. When the button is clicked, the inline text is appended to a static buffer. Then the buffer is displayed in the form's canvas. } procedure TForm1.Button1Click(Sender: TObject); const Turbo: PChar = 'Object'; Pascal: PChar = 'Pascal'; var S: array[0..15] of Char; begin StrECopy(StrECopy(StrECopy(S, Turbo), ' '), Pascal); Canvas.TextOut(10, 10, string(S)); end;
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
|
What do you think about this topic? Send feedback!
|