basics · intermediate · ~15 min
Look up an option's value in argv.
Implement const char *flag_value(int argc, char **argv, const char *flag) returning the argument immediately after flag, or NULL if flag is absent or has no following argument.
#include <string.h>
#include <stddef.h>
const char *flag_value(int argc, char **argv, const char *flag) {
/* TODO */
return NULL;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.