linux-sysprog · beginner · ~15 min

Is it an absolute path?

Distinguish absolute from relative paths.

Challenge

execv needs an absolute path (no PATH search). Implement int is_absolute_path(const char *p) returning 1 if p is non-empty and starts with '/', else 0.

Starter code

int is_absolute_path(const char *p) {
    /* TODO */
    return 0;
}

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