home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_08_09
/
8n09064a
< prev
next >
Wrap
Text File
|
1990-06-19
|
1KB
|
46 lines
/*
// LISTING 2
*/
/****************************************************************************
//
// main() - test driver for crc16 function
//
****************************************************************************/
#include <stdio.h>
main(argc, argv)
int argc;
char *argv[];
{
unsigned short crc;
static unsigned char string[40];
string[0] = 'T';
string[1] = (unsigned char)0xd9;
string[2] = (unsigned char)0xe4;
string[3] = NULL;
printf ("The crc of \"T\" is 0xD9E4. crc16 returned 0x%X.\r\n\n",
crc16(string, (short)1));
printf ("The crc of \"T 0xD9 0xE4\" is %X. The value of crc_ok is 0x%X.\r\n\n",
crc16(string, (short)3), crc_ok);
strcpy(string, "THE,QUICK,BROWN,FOX,0123456789");
printf("The crc of \"%s\" is 0x6E20. crc16 returned 0x%X.\r\n\n",
string, crc16(string, strlen(string)));
string[0] = (unsigned char)0x03;
string[1] = (unsigned char)0x3F;
puts("CCITT Recommendation X.25 (1984) Appendix I example:");
printf("\tThe crc of 0x03 0x3F is 0x5BEC. crc16 returned 0x%X.\r\n\n",
crc16(string, (short)2));
puts("strike RETURN to continue...");
getchar();
}