# network_homework4 **Repository Path**: xiaosansh/network_homework4 ## Basic Information - **Project Name**: network_homework4 - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-04-03 - **Last Updated**: 2026-04-03 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Parity Check 本项目实现了一个简单的偶校验检验程序。 ## 接口 ```c int parity_check(const unsigned char *msg, const int msg_length); ``` - `msg` 中元素值为 `0` 表示比特 `0` - `msg` 中元素值为非 `0` 表示比特 `1` - 当消息中值为 `1` 的元素个数为偶数时,函数返回 `1` - 当消息中值为 `1` 的元素个数为奇数时,函数返回 `0` - 若 `msg_length` 为负数,返回 `0` - 若 `msg` 为 `NULL` 且 `msg_length > 0`,返回 `0` ## 文件说明 - `parity_check.h`:函数声明 - `parity_check.c`:函数实现 - `test_parity_check.c`:测试程序 ## 编译与运行 编译测试程序: ```bash cc -Wall -Wextra -Werror -std=c11 parity_check.c test_parity_check.c -o test_parity_check ``` 运行测试: ```bash ./test_parity_check ```