/** * Compile with * * $ gcc -Wall -o fread fread.c */ #include #include #include #include typedef struct __test_s { char mx; uint64_t x[4]; } b; #define bprint(b) printf("[%20lu, %20lu, %20lu, %20lu]\n", b.x[0], b.x[1], b.x[2], b.x[3]) int main(int argc, char *argv[]) { if (argc < 2) { printf("usage: %s ", argv[0]); return 0; } b db; memset(db.x, 0, sizeof(uint64_t) << 2); FILE *in = fopen(argv[1], "rb"); if (in == NULL) { printf("Could not read file '%s'\n", argv[1]); return 0; } size_t n, total = 0; while ((n = fread(db.x, 1, 32, in)) > 0) { bprint(db); memset(db.x, 0, sizeof(uint64_t) << 2); total += n; } printf("Total: %lu bytes\n", total); return 0; }