fork download
  1. #include <iostream>
  2. #include <string.h>
  3.  
  4. uint8_t rfid_id[][8]={
  5. {0xE1,0xAF,0xE4,0xED,0x50,0x1,0x4,0xE0},//#0
  6. {0x6C,0x27,0xE1,0xC0,0x50,0x1,0x4,0xE0},//#1
  7. {0x58,0x2B,0xE1,0xC0,0x50,0x1,0x4,0xE0},//#2
  8. {0xE5,0x2B,0xE1,0xC0,0x50,0x1,0x4,0xE0},//#3
  9. {0x7C,0x2B,0xE1,0xC0,0x50,0x1,0x4,0xE0},//#4
  10. //Loads more
  11. };
  12.  
  13. uint8_t lastUid[] = {0xE1,0xAF,0xE4,0xED,0x50,0x1,0x4,0xE0};
  14.  
  15. void RFIDCompare(){
  16. for (int i=0; i < 5; i++){
  17. if (memcmp(lastUid, rfid_id[i], 8) != 0) {
  18. printf("Wrong\n"); //degugging information
  19. }
  20. else {
  21. printf("Right\n"); //degugging information
  22. }
  23. }
  24. }
  25.  
  26. void RFIDCompare2(){
  27. for (int i=0; i < 5; i++){
  28. if (memcmp(lastUid, rfid_id[i], 8) != 0) {
  29. printf("Wrong\n"); //degugging information
  30. }
  31. else {
  32. printf("Right, breaking the loop\n"); //degugging information
  33. break;
  34. }
  35. }
  36. }
  37.  
  38.  
  39. int main() {
  40.  
  41. RFIDCompare();
  42. printf("\n");
  43. RFIDCompare2();
  44.  
  45. return 0;
  46. }
Success #stdin #stdout 0.01s 5464KB
stdin
Standard input is empty
stdout
Right
Wrong
Wrong
Wrong
Wrong

Right, breaking the loop