1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#include <stdlib.h> #include <stdio.h> #include <string.h> int main (int argc, char **argv) { int i,s=0,t; for (i = 1; i < argc; i++){ sscanf(argv[i], "%X", &t); s+=t; } printf("checksum=%02X\n",(-s)&0xff); return 0; }