cybersecurity · beginner · ~15 min

Count percent signs

Tally format-control characters.

Challenge

Implement int count_percent(const char *s) returning the number of '%' characters — a quick risk indicator for a string about to be used as a format.

Starter code

int count_percent(const char *s) {
    /* TODO */
    return 0;
}

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