linux-sysprog · beginner · ~15 min
Interpret an env var as a boolean.
Implement int env_is_true(const char *name) returning 1 if the variable is set to exactly "1" or "true", else 0.
#include <stdlib.h>
#include <string.h>
int env_is_true(const char *name) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.