fork(1) download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. // your code goes here
  5.  
  6. unsigned short int crc = 0; // Result
  7. unsigned char command[4]={0x69,0x05,0x00,0x00};// command, ID, arg1, arg2
  8.  
  9. char x, y;
  10. crc=0xFFFF; //init value
  11.  
  12. for (x=0; x<4; x++)
  13. {
  14. crc = ( ( command[x] <<8 ) ^ crc);
  15. for ( y=0; y<8; y++ )
  16.  
  17. {
  18. if ( crc & 0x8000 )
  19. crc = (crc << 1) ^ 0x8005;
  20.  
  21. else
  22. crc = crc << 1;
  23.  
  24. }
  25. }
  26. printf ("CRC: %X\n",crc); // must print CRC:
  27. return 0;
  28. }
  29.  
Success #stdin #stdout 0s 5300KB
stdin
Standard input is empty
stdout
CRC: B471