for i:=1 to len-1 do
begin
     showbuffer[showw][i]:= buf[i];
end;有没函数能实现以上功能的?

解决方案 »

  1.   

    Move(SourceArray[0], DestArray[0], Length(SourceArray));
      

  2.   

    在結構對齊的情況下, Move ,CopyMemory  都可以,我建議你就用自己寫的函數,不然有些沒有必要的錯誤反而會因為你的不了解而產生。
      

  3.   

    //也可以用CopyReturns a substring of a string or a segment of a dynamic array.UnitSystemCategorystring handling routinesDelphi syntax:function Copy(S; Index, Count: Integer): string;
    function Copy(S; Index, Count: Integer): array;DescriptionS is an expression of a string or dynamic-array type. Index and Count are integer-type expressions. Copy returns a substring or subarray containing Count characters or elements starting at S[Index]. The substring or subarray is a unique copy (that is, it does not share memory with S, although if the elements of the array are pointers or objects, these are not copied as well.)If Index is larger than the length of S, Copy returns an empty string or array.If Count specifies more characters or array elements than are available, only the characters or elements from S[Index] to the end of S are returned.Note: When S is a dynamic array, you can omit the Index and Count parameters and Copy copies the entire array.
      

  4.   

    除非你十分熟悉delphi的类型,清楚自己的行为会不会带来什么负面的影响,否则不要轻易用Move等直接内存复制的方式对待由delphi管理生存期的变量
    动态数组的话,应该使用Copy进行复制,它调用了System._DynArrayCopyRange进行复制,可以看到里面会传入一个TypeInfo,用于自动生存期类型的管理
    如果直接Move一个动态string数组而不把前一个清空的话,很可能会引发不能正确释放变量的错误