file-handling · intermediate · ~15 min
Query file metadata without opening the file.
Implement long stat_size(const char *path) returning the file size using stat() (st_size), or -1 if stat fails.
#include <sys/stat.h>
long stat_size(const char *path) {
/* TODO */
return -1;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.