file-handling · intermediate · ~15 min

Write one binary int

fwrite a single fixed-size value.

Challenge

Implement int write_int_binary(const char *path, int v) writing the int v (native layout) to path. Return 0 on success, -1 on failure.

Starter code

#include <stdio.h>

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

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