#include #include #include #include #include #include #include const char *get_packet_name(const char *filename, int num) { static char buf[256] = {0}; sprintf(buf, "%s.%d", filename, num); return buf; } int main(int argc, char const *argv[]) { //打开输入文件 int fd = open(argv[1], O_RDONLY); if (fd < 0) { perror("openfail"); exit(-1); } int fileindex = 1; uint32_t sumcheck = 0; uint8_t *data = malloc(100 * 1024 * 1024); if (data == NULL) { perror("malloc fail"); exit(-1); } while (1) { int readlen = read(fd, data, 100 * 1024 * 1024); if (readlen <= 0) { printf("write end\n"); break; } for (size_t i = 0; i < readlen; i++) { sumcheck += data[i]; } } printf("sumcheck %d\n", sumcheck); return 0; }