cybersecurity · intermediate · ~15 min · safe pentest lab
Filter lines by suffix.
Group enumerated hosts by parent domain: count how many lines end with a given suffix.
Implement int count_of_domain(const char *list, const char *domain) that returns how many lines end with the string domain (e.g. ".example.com").
list: a NUL-terminated, \n-separated string of host entries baked into the harness.domain: the suffix to match (NUL-terminated).Returns int: the number of lines whose final characters equal domain.
list: "a.example.com\nb.other.com\nc.example.com\n"
count_of_domain(list, ".example.com") -> 2
domain cannot match.A NUL-terminated \n-separated host list and a suffix string domain.
An int: the number of lines ending with domain.
Suffix match each line against domain. Static string only.
#include <string.h>
int count_of_domain(const char *list, const char *domain) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.