如何将一个256字节长的pchar变量拆分成若干个16字节长的pchar变量。
或这样的问题有什么其他好的方法。

解决方案 »

  1.   

    给你示范一个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;
      

  2.   

    直接copy到Array[0..3] of array[0..3]我无法处理最后一个#0,作成Array[0..4] of array[0..4]有得做循环补#0,所以想到了变体记录,不知道还有没有好的办法
      

  3.   

    先转成String型,再截成一个个16字节长的变量后再转成Pchar就可以了。