首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

delphi指针有关问题

2012-03-26 
delphi指针问题VarS:stringL:integerbegins: lxpbuaa l:PInteger(Pinteger(@s)^-4)^end谁能说一下上

delphi指针问题
Var
    S:string;
    L:integer;
begin
    s:= 'lxpbuaa ';
    l:=PInteger(Pinteger(@s)^-4)^
end;

谁能说一下上面的代码,越详细越好!

[解决办法]
取故国晚秋GG的针针
[解决办法]
就是取串长度。
Delphi的string是一个指针,指向串存储的空间,在此空间之前的4字节是串长度,再前4个字节是引用计数。

[解决办法]
@S取s的地址 ,Pinteger(@s) 转化为整形类型的指针,Pinteger(@s)^ 转换成后的值
PInteger(Pinteger(@s)^-4) 转换成整形指针PInteger(Pinteger(@s)^-4)^ 取值

热点排行