basics · intermediate · ~15 min

Parse two integers

Tokenise a small input line.

Challenge

Implement int parse_pair(const char *s, int *a, int *b) parsing two non-negative integers separated by a single space (e.g. "12 34"). Return 1 on success, 0 otherwise.

Starter code

int parse_pair(const char *s, int *a, int *b) {
    /* TODO */
    return 0;
}

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