networking · beginner · ~15 min

Count hextet groups

Tokenise an IPv6 address by ':'.

Challenge

Implement int count_groups(const char *addr) returning the number of ':'-separated groups in an IPv6 address written in full form (no '::' compression). That is colons + 1.

Starter code

int count_groups(const char *addr) {
    /* TODO */
    return 0;
}

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