file-handling · intermediate · ~15 min
Measure a file with fseek + ftell.
Implement long file_size(const char *path) returning the file's size in bytes (seek to the end, then ftell), or -1 if it can't be opened.
#include <stdio.h>
long file_size(const char *path) {
/* TODO */
return -1;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.