频道分类

delphi 有关PChar.StrCopy的实验

作者:admin 来源: 日期:2020/3/10 15:44:17 人气: 标签:

 
procedure TForm1.Btnx_1Click(Sender: TObject);
var
  StrxA:string;
  PStrA:PChar;
begin
  StrxA:='330226198501017036';
  Application.MessageBox(PChar(StrxA),'');
  GetMem(PStrA,100);
  StrCopy(PStrA,PChar(StrxA));
  Application.MessageBox(PStrA,'');
end;

procedure TForm1.Btnx_2Click(Sender: TObject);
const
  P1: PChar = 'CodeGear';
  P2: PChar = 'Delphi';
var
  S: array[0..15] of Char;
begin
  StrCopy(S, P1);
  StrCat(S, ' ');
  StrCat(S, P2);
  ShowMessage(StrPas(S)); {CodeGear Delphi}
  ShowMessage(S);         {CodeGear Delphi}
end;