Created
March 5, 2009 15:01
-
-
Save funkaoshi/74373 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "unistd.h" | |
#include "stdio.h" | |
/* Reads one line of data and produces the LRC of all the bytes read. */ | |
int main ( int argc, char* argv[] ) | |
{ | |
char buf[1]; | |
int n, lrc = 0; | |
while ( n = read(0, buf, 1) > 0 ) /* read one byte from std::in */ | |
{ | |
if ( buf[0] == '\n' ) | |
break; | |
lrc ^= buf[0]; | |
} | |
printf("LRC = %02X\n", lrc); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment