cybersecurity · intermediate · ~15 min

Parse a bounded unsigned int

Parse defensively with a value ceiling.

Challenge

Implement int parse_uint_max(const char *s, int max, int *out) parsing a non-negative decimal integer, returning 1 if it's all digits and <= max, else 0.

Starter code

int parse_uint_max(const char *s, int max, int *out) {
    /* TODO */
    return 0;
}

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