linux-sysprog · intermediate · ~15 min
Walk the process environment.
Implement int env_count_with_prefix(const char *prefix) returning the number of environment variables whose name starts with prefix. Use the global environ array.
#include <unistd.h>
#include <string.h>
extern char **environ;
int env_count_with_prefix(const char *prefix) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.