CRC calculation

A

ALuPin

Hi,

I have found a piece of C code for checksum calculation
CRC16 ccitt.

Is that right?
How can I initialize crc?




#include <stdio.h>

int crc_1021(int data)
{

int x;

x = ((crc>>8) ^ data) & 0xff;
x ^= x>>4;
crc = (crc << 8) ^ (x << 12) ^ (x <<5) ^ x;
crc &= 0xffff;

return(crc);

}

int main()

{
int crc
printf("The CRC16-X25_ccitt of %d is %d. \n", crc, crc_1021(crc));
return 0;
}
 
G

Grumble

ALuPin said:
I have found a piece of C code for checksum calculation
CRC16 ccitt.

Is that right?
How can I initialize crc?

Errr. Where is your question about the C language?
 
J

Jack Klein

Hi,

I have found a piece of C code for checksum calculation
CRC16 ccitt.

Is that right?
How can I initialize crc?




#include <stdio.h>

int crc_1021(int data)
{

int x;

x = ((crc>>8) ^ data) & 0xff;
x ^= x>>4;
crc = (crc << 8) ^ (x << 12) ^ (x <<5) ^ x;
crc &= 0xffff;

return(crc);

}

int main()

{
int crc

Change the line above to:

int crc = /* whatever initial value you want */
 
X

xarax

ALuPin said:
Hey,

if you do not want to help then SHUT UP.

Thank you very much.

Best regards

You are posting your question in the wrong
group, so please take your own advice.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top