delphi中String,PChar,PByte,Array of Char,Array of Byte 转换
vars:string;
pc:pchar;
pb:pbyte;
ac:array[1..100] of char;
ab:array[1..100] of byte;
i:integer;
begin
s:='this is a test';
pc:=pchar(s); //string->pchar
pb:=pbyte(pc); //pchar->pbyte
for i:=1 to length(s) do
begin
ac[i]:=s[i]; //string->arrary of char
ab[i]:=byte(s[i]); //string->arrary of byte
end;
s:=pc; //pchar->string
s:=string(pb); //pbyte->string
s:=c; //arrary of char->string;
end;
本文介绍了在Delphi中如何进行String、PChar、PByte、ArrayofChar及ArrayofByte之间的相互转换。通过实例演示了从字符串到字符指针、字节指针以及字符和字节数组的转换过程。

2517

被折叠的 条评论
为什么被折叠?



