C
chenxing516
Unregistered / Unconfirmed
GUEST, unregistred user!
int calcrc(char *ptr, unsigned char count) //计算CRC
{
int crc = 0;
char i,j;
for(j=0;j<count;j++)
{
crc = crc ^ (int) *ptr++ << 8;
i = 8;
do
{
if (crc &
0x8000)crc = crc << 1 ^ 0x1021;
else
crc = crc << 1;
} while(--i);
}
return (crc);
}
转换后的
function calcrc(checkstring:string):string;
var
i,j:integer;
s:string;
crc:word;
begin
crc:=0;
s:= checkstring;
for i:=1 to length(s)do
begin
crc:=crc xor ord(s) shl 8 ;
for j:=0 to 7do
begin
if (crc and $8000)=1 then
begin
crc:=crc shl 1 xor $1021;
end
else
crc:=crc shl 1;
end;
end;
result :=inttostr(crc);
end;
不知道哪有问题 如果c的输入的是0123456789的话 在delphi中求得的值不一样
{
int crc = 0;
char i,j;
for(j=0;j<count;j++)
{
crc = crc ^ (int) *ptr++ << 8;
i = 8;
do
{
if (crc &
0x8000)crc = crc << 1 ^ 0x1021;
else
crc = crc << 1;
} while(--i);
}
return (crc);
}
转换后的
function calcrc(checkstring:string):string;
var
i,j:integer;
s:string;
crc:word;
begin
crc:=0;
s:= checkstring;
for i:=1 to length(s)do
begin
crc:=crc xor ord(s) shl 8 ;
for j:=0 to 7do
begin
if (crc and $8000)=1 then
begin
crc:=crc shl 1 xor $1021;
end
else
crc:=crc shl 1;
end;
end;
result :=inttostr(crc);
end;
不知道哪有问题 如果c的输入的是0123456789的话 在delphi中求得的值不一样