basics · intermediate · ~15 min
Iterate argv the way a CLI parser does.
Implement int count_flags(int argc, char **argv) returning how many arguments (excluding argv[0]) start with '-'.
int count_flags(int argc, char **argv) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.