给你示范一个16分4*4的type TCharArray=Array[0..3] of array[0..3] of char; Tbytearray=array[0..16] of char; //strcopy的时候要补#0,所以多一个 Ttest=record case byte of 0:(Pchar16:TbyteArray); 1:(Pchar4: TCharArray); end; procedure TForm1.BitBtn1Click(Sender: TObject); var test:Ttest; p:pchar; begin p:='0123456789ABCDEF'; strcopy(test.Pchar16,p); showmessage(Test.Pchar4[1]); end;
直接copy到Array[0..3] of array[0..3]我无法处理最后一个#0,作成Array[0..4] of array[0..4]有得做循环补#0,所以想到了变体记录,不知道还有没有好的办法
TCharArray=Array[0..3] of array[0..3] of char;
Tbytearray=array[0..16] of char; //strcopy的时候要补#0,所以多一个
Ttest=record
case byte of
0:(Pchar16:TbyteArray);
1:(Pchar4: TCharArray);
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
var test:Ttest;
p:pchar;
begin
p:='0123456789ABCDEF';
strcopy(test.Pchar16,p);
showmessage(Test.Pchar4[1]);
end;