file-handling · intermediate · ~15 min

Read one binary int

fread a fixed-size record.

Challenge

Implement int read_int_binary(const char *path, int *out) reading a single int (native layout) from the start of the file into *out. Return 0 on success, -1 on any failure.

Starter code

#include <stdio.h>

int read_int_binary(const char *path, int *out) {
    /* TODO */
    return -1;
}

Solve this exercise in the browser editor — compile and run against the test harness, no setup required.