networking · beginner · ~15 min

Is this a localhost name?

Recognise local-only test targets.

Challenge

Implement int is_localhost(const char *host) returning 1 for "localhost", "127.0.0.1", or "::1", else 0.

Starter code

#include <string.h>

int is_localhost(const char *host) {
    /* TODO */
    return 0;
}

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