求助:byte数组读取问题
比如我要从28位开始读取2个字节转成整形,从34开始读取4个字节转成整形,该如何处理。
[解决办法]
c : array[0..49] of byte;
idx : integer;
---------
result := 0;
for idx := 27 to 28 do
begin
result := (result shl 8) or c[idx];
end;
//c : 改为byte数组,nDigits为长度
function Calculate(c: PChar; nDigits: Integer): Integer;
var n : Integer;
begin
Result := 0;
for n := 0 to nDigits - 1 do
Result := ( Result shl 8 ) or Byte(c[n]);
end;