其他分享
首页 > 其他分享> > SysUtils.StrEnd、SysUtils.StrLen

SysUtils.StrEnd、SysUtils.StrLen

作者:互联网

SysUtils.StrEnd、SysUtils.StrLen

StrEnd 获取 PChar 串未指针; StrLen 获取 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}

//StrEnd:
procedure TForm1.Button1Click(Sender: TObject);
var
  p: PChar;
  str: string;
begin
  str := '123456789';
  p := StrEnd(PChar(str));
  ShowMessage(p-3); {789}
end;

//StrLen:
procedure TForm1.Button2Click(Sender: TObject);
var
  p: PChar;
  i: Integer;
begin
  p := '123456789';

  i := StrLen(p);
  ShowMessage(IntToStr(i)); {9}

  i := Length(p);
  ShowMessage(IntToStr(i)); {9}
end;

end.
SysUtils 单元下的公用函数目录

posted on 2008-05-12 23:05  万一  阅读(2135)  评论(0)  编辑  收藏

标签:PChar,StrEnd,end,TObject,SysUtils,StrLen
来源: https://blog.51cto.com/u_14617575/2746262