Created
August 6, 2012 11:48
-
-
Save qxj/3273821 to your computer and use it in GitHub Desktop.
crc32 in zlib
This file contains hidden or 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
/* @(#)test_crc32.cpp | |
* Time-stamp: < 2011-12-26 11:30:17> | |
* Copyright 2011 | |
* Version: $Id: test_crc32.c,v 0.0 2011/12/26 03:25:28 jqian Exp $ | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <zlib.h> | |
void test_crc32(const char* str){ | |
uLong crc = crc32(0L, Z_NULL, 0); | |
int len = strlen(str); | |
crc = crc32(crc, (const Bytef*)str, len); | |
printf("%u\n", crc); | |
} | |
int main(int argc, char *argv[]){ | |
const char str[5][10] = { | |
"123455", | |
"123456", | |
"123457", | |
"123458", | |
"123459" | |
}; | |
for (int i = 0; i < 5; ++i) { | |
test_crc32(str[i]); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment