News for hackers. Stuff that matters.
Re:Show HN: Super Simple CRC32 Implementation by Someone on Tuesday October 29, 2024 @12:27PM (#41986047)
I suggest you write a few test cases to verify that it works reliably. I have my doubts about that, given this code fragment:

    // stop hashing when there is nothing left to hash
    while (scanf("%d", &ch) != EOF) {
        // get the current byte
        ch = getchar();
Re:Show HN: Super Simple CRC32 Implementation by dch82 on Tuesday October 29, 2024 @02:51PM (#41988053)
I replaced that code with

  // loop until an EOF is read
  while ((ch = getchar()), ch != EOF) {
Would this be better?
Re:Show HN: Super Simple CRC32 Implementation by dch82 on Tuesday October 29, 2024 @01:48PM (#41987374)
How would you suggest I replace that? I am a C novice but I have heard of the buffer overflows caused by scanf.