fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4.  
  5. int i;
  6. int xor = 0;
  7. int b;
  8. // $GPGLL,,,,,,V,N*64
  9.  
  10. char Received[18]= {'$','G','P','G','L','L','500.789',',',',',',',',',',','V',',','N','*','6','5'};
  11. int loop;
  12.  
  13. // display array
  14. for(loop = 0; loop < 18; loop++)
  15. printf("%c", Received[loop]);
  16. printf("%c\n ");
  17.  
  18.  
  19. for(int i = 1; i<=14; i++)
  20. xor ^= Received[i];
  21. printf("%#02x ", xor);
  22. printf("%d ", xor);
  23.  
  24. b = ((Received[16]-'0') *16) + Received[17]-'0';
  25. printf("%d ", b);
  26.  
  27. if(xor == b){
  28. printf("WORKING!");
  29. }
  30. else{
  31. printf("not working");
  32. }
  33.  
  34. return 0;
  35. }
Success #stdin #stdout 0s 9424KB
stdin
Standard input is empty
stdout
$GPGLL9,,,,,V,N*65`
 0x71  113 101 not working