#include
unsigned char calc_checksum(const char *s)
{
unsigned char result;
result = 0;
s++; // Skip dollar sign
while ((*s != '*') && (*s != '\0'))
result ^= *s++;
return result;
}
int main()
{
unsigned char checksum;
checksum = calc_checksum
("$GPRMC,235947.000,V,0000.0000,N,00000.0000,E,,,041299,,*");
printf("Checksum = %02X\n", checksum);
return 0;
}
I want same output in C# as i am getting in this c++ code. Please reply soon, Its very urgent.


VulpesRank #55 · 29.2K reputationPosted Oct 11, 2013, 3:33 AM EDT
VulpesRank #55 · 29.2K reputationPosted Oct 11, 2013, 3:08 AM EDT
Checksum = 1D
as the C++ version.
You'll need to compile with the /unsafe switch or 'use unsafe code' if building from VS:
Puneet GuptaRank #2,006 · 724 reputationPosted Oct 11, 2013, 4:06 AM EDT
Thanks,
Puneet Gupta