networking · beginner · ~15 min
Whitelist the legal hostname characters.
Implement int valid_hostname_char(char c) returning 1 for letters, digits, '-' and '.', else 0.
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.