networking · beginner · ~15 min

Is it a loopback address?

Recognise the loopback range.

Challenge

Implement int is_loopback(int a, int b, int c, int d) returning 1 if the dotted-quad address is in 127.0.0.0/8 (first octet 127), else 0.

Starter code

int is_loopback(int a, int b, int c, int d) {
    /* TODO */
    return 0;
}

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