file-handling · beginner · ~15 min

Is a file readable?

Open a file and check the result of fopen.

Challenge

Implement int file_readable(const char *path) returning 1 if the file can be opened for reading (and closing it again), else 0.

Starter code

#include <stdio.h>

int file_readable(const char *path) {
    /* TODO */
    return 0;
}

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