Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Example program
- #include <iostream>
- #include <string>
- #include <sstream>
- #include <fstream>
- using namespace std;
- int main()
- {
- std::stringstream tocomp;
- std::string CalculatedHexNumber;
- char total;
- std::string NMEAcode = "GPGGA094642.0003723.1622N00559.5717W1038.0MM";
- for (char &c : NMEAcode)
- total ^= c;
- tocomp << hex << (int)total;
- CalculatedHexNumber = tocomp.str();
- cout<<"The hex number calculated = " << CalculatedHexNumber << endl;
- NMEAcode = "GPGGA094642.0003723.1622N00559.5717W1038.0MM*77";
- std::string ParsedHexNumber;
- int starB4placeint = NMEAcode.find("\*");
- ParsedHexNumber= NMEAcode.substr(starB4placeint + 1, NMEAcode.length() - starB4placeint);
- cout << "The hex number parsed = " << ParsedHexNumber <<endl;
- if(ParsedHexNumber == CalculatedHexNumber)
- {
- cout << "yo these are both the same and totally valid dawg" << endl;
- }
- else
- {
- cout << "dawg they different, it ain't valid bro" << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement