basics · beginner · ~15 min

Count format specifiers

Scan a format string handling the `%%` escape.

Challenge

Implement int count_format_specs(const char *fmt) returning the number of conversion specifiers — a % followed by a non-% character. %% is a literal percent and does not count.

Starter code

int count_format_specs(const char *fmt) {
    /* TODO */
    return 0;
}

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