networking · beginner · ~15 min
Strict integer parsing with a domain check.
Implement int parse_port(const char *s) returning the port number (1..65535) or -1 on bad input (non-digit chars, out of range).
int parse_port(const char *s) { /* TODO */ return -1; }
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.