【发布时间】:2015-09-03 12:51:49
【问题描述】:
鉴于以下情况:
LBytes: TBytes;
LArr: array[1..512] of Byte;
...
SetLength(LBytes, 512);
将所有字节从 LBytes 复制到 LArr 的正确 Move() 调用是什么?
Move(LBytes[0], LArr, Length(LBytes)); // works
Move(LBytes[0], LArr[1], Length(LBytes)); // works, too
Move(LBytes, LArr[1], Length(LBytes)); // fail
有人能解释一下为什么使用 Larr 和 Larr[1] 没有区别,但在 LBytes[0] 和 LBytes 之间有区别吗?
【问题讨论】:
-
LBytes -> 指向 TBytes 的指针,LBytes[ 0 ] 指向第一个元素。 LArr 是一个固定大小的数组,因此 LArr 和 LArr[1] 相同(例如指向第一个元素)。因此前两个是正确的。使用您认为最易读的任何内容。