Skip to content

Instantly share code, notes, and snippets.

@funkaoshi
Created March 5, 2009 15:01
Show Gist options
  • Save funkaoshi/74373 to your computer and use it in GitHub Desktop.
Save funkaoshi/74373 to your computer and use it in GitHub Desktop.
#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