var
s: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转来BYTE再转回STRING的方法或代码Byte是8位的,只能代表一个字符。所以应该只有在String只有一位时才能转。String只有一位那就是个Char所以用Ord()和Chr()两个函数就可以互相转。