本文整理自网络,侵删。
//把源串添加到目标串后, 要求目标串必须有足够的空间StrCat( Dest: PChar; {目标串} const Source: PChar {源串}): PChar; {返回目标串}
unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;
type TForm1 = class(TForm) Button1: TButton; Button2: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); end;
var Form1: TForm1;
implementation
{$R *.dfm}
//测试 1:procedure TForm1.Button1Click(Sender: TObject);var p1,p2,p3: PChar;begin p1 := 'abc'; p2 := '123';
GetMem(p3, Length(p1) + Length(p2)); StrCat(p3,p1); StrCat(p3,p2);
ShowMessage(p3); {abc123}
FreeMem(p3);end;
//测试 2:procedure TForm1.Button2Click(Sender: TObject);var arr: array[0..20] of Char; pc: PChar;begin arr := 'Embarcadero'; pc := StrCat(@arr, ' Delphi'); ShowMessage(PChar(@arr)); {显示: Embarcadero Delphi} ShowMessage(pc); {显示: Embarcadero Delphi}end;
end.
https://www.cnblogs.com/del/archive/2008/05/12/1193623.html
相关阅读 >>
Delphi 权限控制(Delphi tactionlist方案)
Delphi 获取指定年月的周、日数 -weeksinayear、weeksinyear、daysinayear、daysinamonth、daysinyear、daysinmonth
更多相关阅读请进入《Delphi》频道 >>