Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. // Example program
  2. #include <iostream>
  3. #include <string>
  4. #include <sstream>
  5. #include <fstream>
  6. using namespace std;
  7. int main()
  8. {
  9.  
  10. std::stringstream tocomp;
  11. std::string CalculatedHexNumber;
  12. char total;
  13. std::string NMEAcode = "GPGGA094642.0003723.1622N00559.5717W1038.0MM";
  14. for (char &c : NMEAcode)
  15. total ^= c;
  16. tocomp << hex << (int)total;
  17. CalculatedHexNumber = tocomp.str();
  18.  
  19. cout<<"The hex number calculated = " << CalculatedHexNumber << endl;
  20.  
  21. NMEAcode = "GPGGA094642.0003723.1622N00559.5717W1038.0MM*77";
  22. std::string ParsedHexNumber;
  23. int starB4placeint = NMEAcode.find("\*");
  24. ParsedHexNumber= NMEAcode.substr(starB4placeint + 1, NMEAcode.length() - starB4placeint);
  25. cout << "The hex number parsed = " << ParsedHexNumber <<endl;
  26.  
  27.  
  28. if(ParsedHexNumber == CalculatedHexNumber)
  29. {
  30. cout << "yo these are both the same and totally valid dawg" << endl;
  31. }
  32. else
  33. {
  34. cout << "dawg they different, it ain't valid bro" << endl;
  35. }
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement