String,PChar,PByte,Array of Char,Array of Byte

作者:袖梨 2022-06-25

string,pchar,pbyte,array of char,array of byte

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;

相关文章

精彩推荐