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 单元下的公用函数目录SysUtils.StrEnd、SysUtils.StrLen
原创
©著作权归作者所有:来自51CTO博客作者JLee79的原创作品,请联系作者获取转载授权,否则将追究法律责任
StrEnd 获取 PChar 串未指针; StrLen 获取 PChar 串长度.
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
一维和二维数组sizeof和strlen的区别
sizeof和strlen的区别
bc 一维数组 二维数组