cybersecurity · intermediate · ~15 min · safe pentest lab

Count subdomains

Count non-empty lines.

Challenge

Size an enumeration wordlist by counting its non-empty lines.

Task

Implement int count_subdomains(const char *list) that returns the number of non-empty newline-separated lines.

Input

  • list: a NUL-terminated, \n-separated string of subdomain entries baked into the harness.

Output

Returns int: the count of lines that contain at least one character.

Example

count_subdomains("a.x.com\nb.x.com\nc.x.com\n")   ->   3
count_subdomains("a.x.com\n\nb.x.com\n")           ->   2   (blank line skipped)

Edge cases

  • Empty lines are not counted.
  • A final line without a trailing newline still counts if non-empty.

Rules

  • Static string only — no DNS or network.

Input format

A NUL-terminated \n-separated subdomain list string.

Output format

An int: the number of non-empty lines.

Constraints

Skip empty lines. Static string only.

Starter code

int count_subdomains(const char *list) {
    /* TODO */
    return 0;
}

Solve this exercise in the browser editor — compile and run against the test harness, no setup required.