Posted By

zava on 08/05/10


Tagged

checksum


Versions (?)

simple string checksum


 / Published in: C
 

  1. //Modular sum
  2. char checksum(char* s)
  3. {
  4. signed char sum = -1;
  5. while (*s != 0)
  6. {
  7. sum += *s;
  8. s++;
  9. }
  10. return sum;
  11. }
  12.  
  13. int main()
  14. {
  15. signed char sum = checksum("Hello world!\n");
  16. printf("%d\n", sum);
  17. return 0;
  18. }

Report this snippet  

You need to login to post a comment.