cybersecurity · advanced · ~15 min · safe pentest lab

Count distinct client IPs

Deduplicate the source IPs in a log.

Challenge

Each log line starts with the client IP. Implement int distinct_ips(const char *log) returning the number of distinct leading IP strings (the token before the first space on each line).

Starter code

#include <string.h>

int distinct_ips(const char *log) {
    /* TODO */
    return 0;
}

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