file-handling · intermediate · ~15 min

Save a record

Serialise a small fixed record to disk.

Challenge

Implement int save_record(const char *path, int id, int score) writing the two ints (id then score, native layout) to path. Return 0 on success, -1 on failure.

Starter code

#include <stdio.h>

int save_record(const char *path, int id, int score) {
    /* TODO */
    return -1;
}

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