networking · beginner · ~15 min

Valid hostname character?

Whitelist the legal hostname characters.

Challenge

Implement int valid_hostname_char(char c) returning 1 for letters, digits, '-' and '.', else 0.

Starter code

int valid_hostname_char(char c) {
    /* TODO */
    return 0;
}

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